Solved

ODBC connect string for SQLEXPRESS

Posted on 2008-10-02
4
578 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 142

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

932 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now