Solved

ODBC connect string for SQLEXPRESS

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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

760 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

20 Experts available now in Live!

Get 1:1 Help Now