C# 建立ODBC DSN 連線到 SQL Server
那個\0很重要。 using System.Runtime.InteropServices; public bool DoDBConnect(string strDSN,string strUID,string strPWD) { try { strConn = “DSN=” + strDSN + “;UID=” + strUID + “;PWD=” + strPWD + “;”; cn = new OdbcConnection(strConn); cmd = new OdbcCommand(); adp = new OdbcDataAdapter(); cmd.CommandType = CommandType.Text; cmd.Connection = cn; } catch { return false; } return true; } [ […]