Question

I have an MSDE installed and I have a DB for it. And on a client computer an ODBC alias (x). I want to connect to this using a .NET4 program written in C#. What connection string should I use if I have only a login name (y) and a password (z)?

Or am I to extract server and database name from the registry?

Was it helpful?

Solution

Try this:

Provider=MSDASQL.1;Data Source=x

where x is your ODBC alias. You will need to add security information to this, as per normal.

OTHER TIPS

http://support.microsoft.com/kb/310988

The example #4 is for the DSN use.

 {
   OdbcConnection cn;
   OdbcCommand cmd;
   string MyString;

   MyString="Select * from Customers";

   cn= new OdbcConnection("dsn=myDSN;UID=myUid;PWD=myPwd;");

   cmd=new OdbcCommand(MyString,cn);

   cn.Open();
   MessageBox.Show("Connected");

   cn.Close();
 }     
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top