Wrox Programmer Forums
|
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
 
Old January 2nd, 2004, 03:49 AM
Registered User
 
Join Date: Jan 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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!

 
Old January 2nd, 2004, 05:56 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.
 
Old January 2nd, 2004, 09:20 PM
Registered User
 
Join Date: Jan 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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!

 
Old January 3rd, 2004, 05:51 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.
 
Old January 4th, 2004, 02:51 AM
Registered User
 
Join Date: Jan 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old January 4th, 2004, 08:33 PM
Registered User
 
Join Date: Jan 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Something I should have added to the above novel: The piece of code it bombs out on is:

MyDataAdapter.SelectCommand.ExecuteNonQuery()

Regards,

Dana

 
Old January 5th, 2004, 05:11 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Try it out:Ch 16 Dataset Example flhartley VB.NET 2002/2003 Basics 1 August 28th, 2009 07:00 AM
Chapter 16 Fig 16-11 krsouthern BOOK: Professional SharePoint 2007 Development ISBN: 978-0-470-11756-9 1 July 8th, 2008 12:11 PM
Chapter 16 boyce0324 VB.NET 2002/2003 Basics 1 June 5th, 2007 01:59 AM
Chapter 16 - DataSet Example - MODIFIED??? cliffd64 VB.NET 2002/2003 Basics 2 May 17th, 2005 12:52 PM
DataSet example, Chapter 16 jtimms BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 13 October 11th, 2003 05:03 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.