Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning Microsoft Visual Basic 2008 ISBN: 978-0-470-19134-7
This is the forum to discuss the Wrox book Beginning Microsoft Visual Basic 2008 by Thearon Willis, Bryan Newsome; ISBN: 9780470191347
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Microsoft Visual Basic 2008 ISBN: 978-0-470-19134-7 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #11 (permalink)  
Old February 6th, 2010, 12:13 PM
Authorized User
Points: 406, Level: 7
Points: 406, Level: 7 Points: 406, Level: 7 Points: 406, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2005
Location: Florida
Posts: 88
Thanks: 4
Thanked 0 Times in 0 Posts
Default Chapter 17 Connection String

Thank you bnews987 for very patiently trying to help.

We passed a milestone. I no longer get this error:

"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)"

When using this code:
Code:
Dim objConnection As SqlConnection = New SqlConnection("Server=SIRMILT-PC\SQLEXPRESS;Trusted_Connection=True;Database=PUBS;")
I now get this error:
Cannot open database "PUBS" requested by the login. The login failed. Login failed for user 'sirmilt-PC\sirmilt'.

I have tried variations using "Integrated Security" rather then "Trusted_Connection" to no avail. I even tried using the User ID in Windows, I have no password set up.

Are there any further suggestions as to where I can search for a solution?

Thanks,
sirmilt
Reply With Quote
  #12 (permalink)  
Old February 7th, 2010, 11:14 PM
Wrox Author
Points: 330, Level: 6
Points: 330, Level: 6 Points: 330, Level: 6 Points: 330, Level: 6
Activity: 42%
Activity: 42% Activity: 42% Activity: 42%
 
Join Date: Mar 2006
Location: , , .
Posts: 90
Thanks: 0
Thanked 5 Times in 5 Posts
Default

This beginners book does not go into integrated security which is how you are trying to do this. To make it work you will need to chagne the security inside of SQL Server. The problem is the user being passed to SQL does not have access to the DB. To get around this, you should use a connection string like is in the book and turn on mixed mode authentication so the examples in the book will work. The steps for this were in the setup on SQL Server but you can change the database after installation. Use the info here http://msdn.microsoft.com/en-us/libr...0(SQL.90).aspx (2005) or here http://msdn.microsoft.com/en-us/library/ms188670.aspx (2008) to change your database to mixed mode. Give the sa account a password and then use a connection like in chapter 17. For your setup, it would be

Code:
Dim objConnection As SqlConnection = New SqlConnection("Server=SIRMILT-PC\SQLEXPRESS;Database=PUBS; user id=sa; password=your_sa_password")
After this, it should work fine. Hopefully:). Don't give up on sql server as it is very powerful. Bryan

Last edited by bnews987; February 7th, 2010 at 11:16 PM. Reason: added 2nd link
Reply With Quote
  #13 (permalink)  
Old February 8th, 2010, 09:41 AM
Authorized User
Points: 406, Level: 7
Points: 406, Level: 7 Points: 406, Level: 7 Points: 406, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2005
Location: Florida
Posts: 88
Thanks: 4
Thanked 0 Times in 0 Posts
Default SQL Connection String -Chapter 17

Thank you for the response and your attempts to help. I do not use a password so I used your suggested connection string as follows:

[code] Dim objConnection As SqlConnection = New SqlConnection("Server=SIRMILT-PC\SQLEXPRESS;Database=PUBS; user id=sa; password=;")[\code]

Unfortunately, it didn't work, the same error was thrown:
"Login failed for user 'sa'. "

Milt
Reply With Quote
  #14 (permalink)  
Old February 8th, 2010, 10:53 AM
Wrox Author
Points: 330, Level: 6
Points: 330, Level: 6 Points: 330, Level: 6 Points: 330, Level: 6
Activity: 42%
Activity: 42% Activity: 42% Activity: 42%
 
Join Date: Mar 2006
Location: , , .
Posts: 90
Thanks: 0
Thanked 5 Times in 5 Posts
Default

What version of SQL are you using? This should work so we are mising something simple.

Can you log in as SA no password using sql management studio? Please verify that you can login to that SQL instance using another tool and see the database tables. Do things like select the data from the table or edit the data from within management studio. If you can do that, then this should work also and we need to look at other items. Bryan
Reply With Quote
  #15 (permalink)  
Old February 8th, 2010, 11:20 AM
Authorized User
Points: 406, Level: 7
Points: 406, Level: 7 Points: 406, Level: 7 Points: 406, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2005
Location: Florida
Posts: 88
Thanks: 4
Thanked 0 Times in 0 Posts
Default Chapter 17 Connection String

I am using SQL Server Express 2008.

The login for SQL Management Studio does not give me the option to change the User unless I change from Windows Authentication to SQL Server Authentication.

I tried that and it would not connect.

Would I solve this problem if I used the SQL Server Authentication, assigned a User ID and password? If so, how would this affect the ultimate User?

Milt
Reply With Quote
  #16 (permalink)  
Old February 8th, 2010, 01:16 PM
Wrox Author
Points: 330, Level: 6
Points: 330, Level: 6 Points: 330, Level: 6 Points: 330, Level: 6
Activity: 42%
Activity: 42% Activity: 42% Activity: 42%
 
Join Date: Mar 2006
Location: , , .
Posts: 90
Thanks: 0
Thanked 5 Times in 5 Posts
Default

yes, you need to change the sa password. I put a link in earlier for how to do that. Then on SQL MS choose SQL Authenticaiton and put sa and the passwords. Once that works, use the last connectstring I added last night that pass a user name and password to the app. This approach stores the login in the app and the users do not need access to the sql server as the app has it. Using windows authenication is common in the enterprise but you would need to do more security setup and analysis to assign rights to users/groups. That is more advanced and not part of this book. Stick with sql authentication early on and you can do everything you need to. Bryan
Reply With Quote
  #17 (permalink)  
Old February 8th, 2010, 04:46 PM
Authorized User
Points: 406, Level: 7
Points: 406, Level: 7 Points: 406, Level: 7 Points: 406, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2005
Location: Florida
Posts: 88
Thanks: 4
Thanked 0 Times in 0 Posts
Default Chapter 17 Connection String

bnews987

Thanks again for trying to help me.

I followed your suggestions exactly. After I set up the 'sa" user and password I can now log into the SQL SMS using either the SQL Server or the Windows authentication. I still get an error "SQL Exception Was Unhandled" - "Cannot open database "PUBS" requested by the login. The login failed. Login failed for user 'sa'."

In the possibility (hopefully remote) that I messed up the connection string here it is exactly.

Dim objConnection As SqlConnection = New SqlConnection("Server=SIRMILT-PC\SQLEXPRESS;Database=PUBS; user id=sa; password=325")


I hate to just give up, but I'm getting very close to making that decision.

Milt
Reply With Quote
  #18 (permalink)  
Old March 1st, 2010, 02:05 PM
Wrox Author
Points: 330, Level: 6
Points: 330, Level: 6 Points: 330, Level: 6 Points: 330, Level: 6
Activity: 42%
Activity: 42% Activity: 42% Activity: 42%
 
Join Date: Mar 2006
Location: , , .
Posts: 90
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Sorry it took so long to get back to you. I mised the email that you had posted a new reply I guess. OK, this may be a dumb question, but did you install the pubs DB on you SQL Server?

We have spent a lot of time with this and there has to be a simple solution. Do this for me and I will help you offline as this not getting anyehere. Click on bnews987 at the top left of this post and it will display a menu. Click to view my public profile and in there you can send me an email? We can setup a time where we can do a net meeting and and I can just look at your machine while you watch and we can solve the problem that way. All we need to do is find a good time for both of us. This should not be this complex and I know it is frustrating but hang in there and we can make it work. Bryan
Reply With Quote
  #19 (permalink)  
Old March 1st, 2010, 06:32 PM
Authorized User
Points: 406, Level: 7
Points: 406, Level: 7 Points: 406, Level: 7 Points: 406, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2005
Location: Florida
Posts: 88
Thanks: 4
Thanked 0 Times in 0 Posts
Default Chapter 17 Connection String

bnews987

After all of my previous frustration I uninstalled SQL Server Express and will continue to use Access.

To answer the specific question, yes, Pubs was installed and I was able to access it in the Management Tools.

Thank you for trying to help,

Milt

I tried to send this message through your profile as you suggested but got a message that this was not permitted.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Errata Chapter 17 sahyouni ASP.NET 2.0 Professional 1 July 9th, 2009 07:07 AM
Chapter 17 HenzFast BOOK: Beginning Microsoft Visual Basic 2008 ISBN: 978-0-470-19134-7 2 April 14th, 2009 04:28 AM
Chapter 17 First Try It Out paloyme BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 7 August 23rd, 2006 12:14 PM
Chapter 17 first Try It Out paloyme Visual Basic 2005 Basics 0 April 17th, 2006 05:34 AM
Chapter 17 Gaby BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 3 September 8th, 2005 12:50 PM



All times are GMT -4. The time now is 07:05 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.