Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ODBC connect string for SQLEXPRESS

Posted on 2008-10-02
4
Medium Priority
?
624 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 2000 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

824 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