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 .
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:
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?
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
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
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
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
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.
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