我有个问题。我写了这个方法来打开sql连接。但它没有用。为什么这不起作用。
public SqlConnection connection( )
{
string DBName = ConfigurationManager.AppSettings["DBName"].ToString();
string ServerName = ConfigurationManager.AppSettings["ServerName"].ToString();
string UserId = ConfigurationManager.AppSettings["UserId"].ToString();
string DBPassword = ConfigurationManager.AppSettings["DBPassword"].ToString();
EMVTool.OSSPwdProcessor PwdPass = new EMVTool.OSSPwdProcessor();
String sClearPwd = "";
if (DBPassword.Length > 40)
sClearPwd = PwdPass.DecryptPwd(DBPassword);
else
sClearPwd = DBPassword;
string ConnectionString = "Server=" + ServerName + ";Database =" + DBName + ";UID =" + UserId + ";PWD =" + sClearPwd + ";MultipleActiveResultSets=True;";
SqlConnection connect = new SqlConnection(ConnectionString);
return connect;
}
我正在调用类似打开sql连接的方法。
connection().Open();