System DSN with SQL Server 200

nagra

New Member
I would like to know if I can use a System DSN to access a SQL Server 2000 db with a code like the following :<BR><BR>dim cn as SqlConnection<BR>dim cm as SqlCommand<BR>...<BR>cn = new SqlConnection("server=localhost;uid=sa;pwd=;database=myclicksdb")<BR>cn.open()<BR>cm = new SqlCommand("InsertPic", cn)<BR>cm.CommandType = CommandType.StoredProcedure<BR>...<BR>cm.ExecuteNonQuery()<BR>cn.close()<BR><BR>can I use the SqlCommand ?? Or I need to use something else?<BR>thanksI don't believe you can use DSNs to connect to databases via the SqlClient provider. Consult the documentation to be certain, but I think you have to connect via the syntax in the example you provide.<BR><BR>If you MUST use a DSN, I believe you have to use the ODBC provider (which is freely available on Microsoft's site for download). Of course, I would imagine this ODBC provider to be slower than the OleDb provider, which is slower than the SqlClient provider.<BR><BR>Why do you need to use a System DSN?I need it beacause it is the only way the provider allows me to connect.<BR>
 
Back
Top