 |
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1). |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

January 2nd, 2004, 03:49 AM
|
Registered User
|
|
Join Date: Jan 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Chapter 16, DataSet Example
I have installed MSDE, gone into the registry, and changed the 'loginmode' to 2 in the DWORD editor. When I set up MSDE, I set an 'sa' password, and 'strong named' the password. Then I rebooted.
I know I have IIS installed correctly (I have some old ASP/VB6/ODBC programs that I tested that work just fine).
The age old problem: Why do I get the "Cannot open database requested in login 'pubs'. Login Fails. Login failed for user 'COMPUTER\Default" error message? (I added a 'try/catch' around 'myConnection.open')
Are IIS/ VB.NET/MDSE not talking to eachother for some reason?
Any help will be appreciated.
Thanks!
|

January 2nd, 2004, 05:56 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
What does your connection string look like? Are you using Integrated Security or SQL Server Security?
And is loginmode 2 Integrated or SQL security?
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|

January 2nd, 2004, 09:20 PM
|
Registered User
|
|
Join Date: Jan 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Right. That would have been good to tell you.
My connection string is:
Dim myConnection As SqlConnection = New SqlConnection("server= (local);database=pubs;uid=sa;pwd=")
Q: Are you using Integrated Security or SQL Server Security?
I shut down the MDSE, went into regedt32, and altered
HKLM\Software\Microsoft\Microsoft SQL Server\MSSQLServer\LoginMode
and changed it to '2' -- mixed mode.
Then I got out of the registry, and restarted MDSE.
I know VB6 had a whole load of 'references that had to be set for OLEDB to work -- is there anything like that in VB.NET, or does it just look like it isn't talking to MSDE?
Thanks!
|

January 3rd, 2004, 05:51 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
Your connection string looks a little weird for a Sql connection. Try this:
New SqlConnection("Data Source=(local);Initial Catalog=pubs;User ID=sa;Password=")
I think your current connection string does not pass over the User ID en Password correctly, so an Integrated connection is assumed.
Is there any specific reason why you're using mixed security? Integrated may be easier and more secure.....
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|

January 4th, 2004, 02:51 AM
|
Registered User
|
|
Join Date: Jan 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
The "Dim myConn As SqlConnection = New SqlConnection("server=(local);database=pubs;uid=sa ;password=")" is the code for DataSet Example in Chapter 16 of 'Beginning VB.VET 2e'.
The solution was twofold: First I downloaded a free application called "DBAMgr2K" that acts as an interface for MSDE. Secondly, I got on the phone with a (new) friend who helped me configure MSDE (with "DBAMgr2K") and hook up the pubs database so I could open it with the string above. I can now connect successfully. I verified the connection is being made with the immediate/command window. Life is good.
New problem: Now when I run the code, it runs just fine up to the line "MyDataAdapter.SelectCommand.ExecuteNonQuery() ", then I get the error, "Invalid object name 'authors'" . . . which is the table I'm trying to get at in the pubs database! I even downloaded the code for the same program off the Wrox website and it does the exact same thing . . . won't access the tables inside the pubs database.
I've seen references all over the web regarding this error message, but no solutions. Anybody out there in Wroxland ever had to fix this one?
Thanks again!
Dana
|

January 4th, 2004, 08:33 PM
|
Registered User
|
|
Join Date: Jan 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Something I should have added to the above novel: The piece of code it bombs out on is:
MyDataAdapter.SelectCommand.ExecuteNonQuery()
Regards,
Dana
|

January 5th, 2004, 05:11 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Did you try the connection string I showed you earlier? That's the "official" connectionstring for a SqlConnection from within .NET.
I think that the connection does not see Database as a correct term, so it tries to look in the Master database. It needs Initial Catalog instead. The stuff you're using is partly out-dated and partly wrong. The fact that you got it to work, doesn't mean it is correct ;)
Replace your connection string with this:
Data Source=(local);Initial Catalog=pubs;User ID=sa;Password="
and I think it will work.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|
 |