Hello NG,
the code below works, but if i add
the outcommented part of it (the Uid and Pwd section) the
function fails and returns false.
Why is that so? Do I have to add a addidinalt Parameter?
Regards
Michael
<CodeSchnipsel>
private bool AddSQLUserDSN(string DSName, string DBPath) {
bool ret;
try{
ret = SQLConfigDataSource((IntPtr)0, 1,
"SQL Server",
"DESCRIPTION="+ DSName + "\0" +
"DSN="+DSName+ "\0" +
"Server="+ this.txtbODBCServer.Text + "\0" +
"Database="+ DSName+ "\0");
// "Uid="+ this.txtBODBCUser.Text + "\0" +
// "pwd="+ this.txtBODBCPassword.Text + "\0");
return ret;
}catch(Exception exc){
MessageBox.Show(exc.Message);
return false;
}
}
Sue Hoegemeier - 22 Nov 2004 20:24 GMT
I don't think specifying uid and pwd with
SQLConfigDataSource API is supported with SQL Server. You
can find the supported attributes for the SQL Server ODNBC
driver at:
http://msdn.microsoft.com/library/en-us/odbcsql/od_odbc_c_99yd.asp
You can specify to use a trusted connection. But as noted in
the docs, if you don't specify a trusted connection then the
User name and password must be provided for each connection.
-Sue
>Hello NG,
>
[quoted text clipped - 28 lines]
> }
>}
Michael Brockhoff - 24 Nov 2004 09:22 GMT
Many thanks.
at least now i know why it does not work.
Regards Michael
>I don't think specifying uid and pwd with
> SQLConfigDataSource API is supported with SQL Server. You
[quoted text clipped - 39 lines]
>> }
>>}