Reputation: 695
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?
Upvotes: 0
Views: 2941
Reputation: 4604
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.
Upvotes: 1
Reputation: 695
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();
}
Upvotes: 1