if you use ODBC, you need to use ODBC.NET, suggest you create a SQL authenticated account in SQL Server, then use
"Server=localhost;Database=YourDBName;UID=YourUID;PWD=YourPassword;" and classes in System.Data.SqlClient namespace

解决方案 »

  1.   

    以下方法不用ODBC也可连接(C#)
    声明using System.Data.SqlClient; 
    连接
    SqlConnection myConnection = new SqlConnection("server=(local);database=你的库名;user id =sa;password=;");
      

  2.   

    ConnectionString:
    server=192.168.0.250;database=violation;user id=sa;password=;
      

  3.   

    Provider=SQLOLEDB; data source=服务器名;user id=sa;password=;initial catalog=数据库名
      

  4.   

    如果你使用的ASP3的话并且使用ODBC则连接串是
    "DSN=ODBCNAME;UID=sa;PWD=sa"
    若使用的是ASP.NET的话,使用OLEDB进行连接的连接串是
    "Data Source=ServerName(or IP address);Provider=SQLOLEDB;User ID=sa;Password=sa;"