objConnection.Open() is highlighted green

  • Thread starter Thread starter ryguy7272
  • Start date Start date
R

ryguy7272

Coming from an Excel/Access background; pretty good VBA experience...I
recently installed SQL Server Express 2008 and VWD 2008. I'm trying to use
VWD to connect to SQL server, based on an example in ch.4 in a book called
'Beginning ASP.NET Databases using VB.NET'. As I mentined in the title, a
line with the syntax objConnection.Open() is highlighted green.
InvalidOperationException was handled by user code. I suspect VWD is not
'seeing' SQL Server, but I don't know what to check, or how to make it work.
I thought I was connected (Tools > Add Connection > Data Source is SQL Server
then browsed to the DB file...named Northwind). When I hit test connection
I received a 'succeeded' message. However, I think I am NOT connected to SQL
Server, and I can’t load the browser...objConnection.Open() is highlighted
green. Not sure what to do now, but I would certainly appreciate some
help/advice.

Thanks!
Ryan--
 
ryguy7272 said:
Coming from an Excel/Access background; pretty good VBA experience...I
recently installed SQL Server Express 2008 and VWD 2008. I'm trying to use
VWD to connect to SQL server, based on an example in ch.4 in a book called
'Beginning ASP.NET Databases using VB.NET'. As I mentined in the title, a
line with the syntax objConnection.Open() is highlighted green.
InvalidOperationException was handled by user code. I suspect VWD is not
'seeing' SQL Server, but I don't know what to check, or how to make it work.
I thought I was connected (Tools > Add Connection > Data Source is SQL Server
I received a 'succeeded' message. However, I think I am NOT connected to SQL
Server, and I can’t load the browser...objConnection.Open() is highlighted
green. Not sure what to do now, but I would certainly appreciate some
help/advice.

Thanks!
Ryan--

The docs say that you would get that exception if the connection was
already opened. Really cannot say more without a code example however.
 
Thanks for the response Mike. The connection being opened produces that
outcome? Somehow, it doesn't seem right. I tried a few things and the
result is pretty much the same. Now, I get a message that says 'the
connectionstring property has not been initialized'. I think it is a result
of a failure to connect to the DB. I can't figure out what to do. I read
the chapter so many times but I'm still not getting it, and I can't get any
code to work because all samples from the book require logging into Access or
SQL Server. Any other thoughts?

Thanks,
Ryan---
 
I went through the steps in the book, and made sure SQL Server starts
automatically. From the Start Menu, open the Control Panel, and go to
Administrative Tools | Services and set SQL Server Express to Status =
Started, Startup Type = Automatic and Log On As = Local System. I think I
have traced the problem to this...
I have MS VB 2008 Express. I think users are supposed to go to ‘Server
Explorer’ and choose Add Connection from the context menu and then choose the
appropriate settings for SQL Server from the dialog box. However, I did some
research online and found out that VB Express doesn’t have a ‘Server
Explorer’. Maybe it is kind of moot, because although I have VB 2008
Express, I will use MS VWD 2008 Express for all my web site development work.


Under tools | Connect to Database, I see 5 databases:
SQL Server (with my server name) sqlexpress.master.dbo
SQL Server (with my server name) sqlexpress.Northwind.dbo
Northwind.mdb
Northwind.MDF
Nwind.mdb
All 5 have a small red x next to them, so I right-click each, modify the
connection, text the connection (succeeds), and click OK. Still, when I go
to File | New Web Site and Browse to the chapter (from the book) that I want
to work with, then Start Debugging, I always get a message that says a
problem with the connection string, such as this ‘The ConnectionString
property has not been initialized’ and then in one file that I am working
with the following line is highlighted green:
objAdapter.Fill(objDataSet, "dtProducts")

Last time, in another chapter, objConnection.Open() was highlighted green

Any thoughts?

Thanks,
Ryan---
 
Back
Top