Solved

ODBC connect string for SQLEXPRESS

Posted on 2008-10-02
4
593 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
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…

697 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