Solved

ODBC connect string for SQLEXPRESS

Posted on 2008-10-02
4
589 Views
Last Modified: 2012-06-27
I can not open SQLExpress using ODBC.
The 1st Open works using the native drivers.
The second open always fails using ODBC.
I have tried all sorts of syntax changes.

     string s1 =@"Data Source=HOME\SQLEXPRESS;Initial Catalog=TESTDB;Integrated Security=True";
            SqlConnection connSQL = new SqlConnection(s1);
            connSQL.Open(); //<<this works

            string s2 = @"Provider=SQLOLEDB.1;Data Source=C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\;Initial catalog=TESTDB; Trusted_connection=yes;";
            OleDbConnection connODBC = new OleDbConnection(s2);
            connODBC.Open(); //this fails with - Message="[DBNETLIB][ConnectionOpen (ParseConnectParams()).]Invalid connection."
0
Comment
Question by:wilfordrocks
  • 2
4 Comments
 
LVL 16

Expert Comment

by:brad2575
ID: 22627609
does your database allow non windows authentication connection?

You can right click the database (from sql server environment) and then click Properties and then security and there is an option in there for windows authentication or SQL authentication and windows

that would be what I would check first.
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 22627705
please try this instead:
string s2 = @"Provider=SQLOLEDB.1;Data Source=.;Initial catalog=TESTDB; Trusted_connection=yes;";

Open in new window

0
 

Author Comment

by:wilfordrocks
ID: 22627818
It is set to Windows Authentication by default.  Switching it does not help.
Thanks anyway.
0
 

Author Closing Comment

by:wilfordrocks
ID: 31502518
You rock my friend.
This string, based on yours, works!
            string s2 = @"Provider=SQLOLEDB.1;Data Source=HOME\SQLEXPRESS;Initial catalog=TESTDB; Trusted_connection=yes;";
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question