OleDB 连接老是写错,郁闷

TMD,我老是写错OLeDB连接的字符串的,还是写在自己的Blog上纪念一下我的失忆症:

本地测试: 

        System.Data.OleDb.OleDbConnection conn  =   new  OleDbConnection( " Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sqlser帐户;Password=sqlserver密码;Initial Catalog=数据库名称;Data Source=CP1897-BRYAN;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=CP1897-BRYAN;Use Encryption for Data=False;Tag with column collation when possible=False; " );
        conn.Open();
        
if  (conn.State  ==  System.Data.ConnectionState.Open)
        
{
            Response.Write(
"Open");
            conn.Close();
        }

        
else
        
{
            Response.Write(
"close");
        }

 

远程连接:

private   static   string  DefaultCDBConnectionString  =   @" Provider=SQLOLEDB.1;Data Source=IP地址,1433;Network Library=DBMSSOCN;Initial Catalog=数据库名称;User ID=sqlserver帐号;Password=sqlserver密码; "  ;

 

 

你可能感兴趣的:(OleDB 连接老是写错,郁闷)