Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB Modules and SQLExpress

Status
Not open for further replies.

tfhwargt3

Programmer
Sep 19, 2006
61
US
I have an access module that parses a file and creates a couple SQL queries within Access and I am migrating to SQL Server Express.

I have MS Visual Basic, and I have created a new DataProject and added a Module, but I am having trouble connecting to my SQL Express Database because what I am finding online is tutorials on connecting via a .mdf file using something like this:

Code:
 Dim cn As ADODB.Connection
    Set cn = New Connection
    cn.ConnectionString = "Provider=SQLNCLI.1;Integrated Security=SSPI;" & _
        "Persist Security Info=False;" & _
        "AttachDBFileName=" & App.Path & "\northwnd.mdf;Data Source=server1\sqlexpress"
    cn.Open

I want to make a persistent connection to the actual database that is live when I do this. It is my understanding that this style of connection is for shipping an application, and that this .mdf string style connection would be on a static form of the database, not the live one. If I am incorrect, and this style of connecting to the DB is actually live, how can I find out where my .mdf file is?

I am understanding this correctly, how would I go about connecting to the live database within Visual Basic so that I may make live charges to the database?
 
You appear to be mixing elements of an ODBC connection string with elements of an OLEDB connection string. In my opinion, OLEDB is far superior to ODBC in terms of performance and reliablility.

Your connection string should look like this...

[tt][blue]Provider=SQLNCLI;Server=[red]myServerName\theInstanceName[/red];
Database=[red]myDataBase[/red];Trusted_Connection=yes;[/blue][/tt]

This is taken from;
You'll need to change the parts in [red]red[/red].

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top