Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases 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 October 30th, 2006, 11:50 PM
Registered User
 
Join Date: Oct 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL Server Express Connection String

In Beginning Visual Basic 2005 Databases, I am trying to figure out what connection string I need for SQL Server Express. I am using the "pubs" database. I have no idea what user ID or password to specify with this Microsoft sample data.

Thank you in advance for your assistance.

Dave Kaufmann

 
Old November 1st, 2006, 05:16 PM
Authorized User
 
Join Date: Oct 2005
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey whats up ...well what you can do is try to make an account in SQL Express or try to use windows authentication integration mode.

But since it seems you want to use SQL authentication then here is a small sample that I've used for testing purpose

//////
 Dim objconnection As New SqlConnection("server=computerxp\sqlexpress; database=pubs; user id =sap; password = test123;")
/////



To break this down its pretty simple..
"Server=computerxp\sqlexpress;"..that is my computername \ sqlexpress instance name

"Database = pubs;...obviously the database name that you want

"user id = sap; password = test123;" ..pretty much I made a user in sqlexpress named 'sap' with the password test123

and that should do it for you.

P.S: also remember to declare at the top of your program
Imports System.Data
Imports System.Data.SqlClient

Good luck


 
Old November 2nd, 2006, 02:37 PM
Registered User
 
Join Date: Oct 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very much. I'll give it a try.

Dave
 
Old November 2nd, 2006, 11:50 PM
Registered User
 
Join Date: Oct 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Finally solved the problem by using Tools - Connect To Database. This utility created a connection string of "Data Source=.\SQLEXPRESS;AttachDbFilename='C:\SQL Server 2000 Sample Databases\PUBS.MDF';Integrated Security=True;Connect Timeout=30;User Instance=True"

The previous attempts at a connection string resulted in an error pertaining to "remote access". I suspect that I might have done something when I installed the sample pubs database. I am really not sure what I was doing wrong, but this new connection string worked.
 
Old November 3rd, 2006, 01:48 PM
Authorized User
 
Join Date: Oct 2005
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by dkaufmann
 Finally solved the problem by using Tools - Connect To Database. This utility created a connection string of "Data Source=.\SQLEXPRESS;AttachDbFilename='C:\SQL Server 2000 Sample Databases\PUBS.MDF';Integrated Security=True;Connect Timeout=30;User Instance=True"

The previous attempts at a connection string resulted in an error pertaining to "remote access". I suspect that I might have done something when I installed the sample pubs database. I am really not sure what I was doing wrong, but this new connection string worked.
Awesome I'm glad it worked for you. As for the remote access error I believe you can fix that by to going to SQL server configuration manager...but since you fixed it through to tools then its all good :D.
One thing though..if you use the tool wizard ..and don't quote me on this because i could be fully wrong..but doesn't the code that it generates then makes it more to machine specific...meaning if you want to transport your program to another machine and run it there it wouldnt run correctly because it was generated by the wizard..
Again I'm not too sure about this, but just wondering about it.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Remote connection error with SQL Server Express DudeBori82 SQL Server 2005 4 April 12th, 2009 01:51 AM
Problem with my sql server express connection saif44 ASP.NET 2.0 Basics 9 June 13th, 2006 05:07 PM
Problem with SQL SERVER Connection String Non Linear BOOK: Beginning ASP 3.0 3 October 20th, 2005 12:35 AM
SQL Server Connection String Nicky2k Classic ASP Basics 4 January 13th, 2005 05:22 AM
connection string for sql server rj1406 ASP.NET 1.0 and 1.1 Basics 6 September 16th, 2004 02:49 PM





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