/// <summary> /// ת�������Ӵ�,SQL��֤ /// </summary> /// <param name="strServerName"></param> /// <param name="strDbName"></param> /// <param name="strUser"></param> /// <param name="strPwd"></param> /// <returns></returns> public static string GetSQLServerOleConnectString(string strServerName, string strDbName, string strUser, string strPwd) { OleDbConnectionStringBuilder builder = new OleDbConnectionStringBuilder(); builder.Clear(); builder.Add("Data Source", strServerName); builder.Add("Initial Catalog", strDbName); //builder.Add("Integrated Security", login.winMode); builder.Add("User ID", strUser); builder.Add("Password", strPwd); builder.Add("Provider", "SQLOLEDB"); //builder.Add("ConnectionTimeout", 120);//����������������ӳ�ʱʱ��,��λ-�� return builder.ConnectionString; }
/// <summary> /// Windows��֤ /// </summary> /// <param name="strServerName"></param> /// <param name="strDbName"></param> /// <returns></returns> public static string GetSQLServerOleConnectString(string strServerName, string strDbName) { //Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=master; OleDbConnectionStringBuilder builder = new OleDbConnectionStringBuilder(); builder.Clear(); builder.Add("Data Source", strServerName); builder.Add("Initial Catalog", strDbName); builder.Add("Integrated Security", "SSPI"); //builder.Add("Persist Security Info=False", "False"); return builder.ConnectionString; }