之前配置好都能用,昨天不能登陆,重启后也可以访问了,今天怎么也访问不了.下面贴了一部分代码,执行到myCn.Open();后接着就跳到myCmd.Dispose();
protected static int ExecuteSql4Value(string strSQL)
{
SqlConnection myCn = new SqlConnection(strConn);
SqlCommand myCmd = new SqlCommand(strSQL,myCn);
try
{
myCn.Open();
object r = myCmd.ExecuteScalar();
if(Object.Equals(r,null))
{
throw new Exception("value unavailable!");
}
else
{
return (int)r;
}
}
catch(System.Data.SqlClient.SqlException e)
{
throw new Exception(e.Message);
}
finally
{
myCmd.Dispose();
myCn.Close();
}
}web.config中<add key="strConnection" value="server=ZHY;User ID=sa;Password=;database=SellServerNew;Connection Reset=FALSE" />
调试信息中
myCn--IsShiloh显示:IsShiloh <error: an exception of type: {System.NullReferenceException} occurred> bool
ServerVersion <error: an exception of type: {System.InvalidOperationException} occurred> string数据库按默认的配置,混合登陆模式,sa用户名,无密码.请大家帮我看看是什么问题啊?