数据库为E-Test,表为students
为什么在winform下运行上面程序,就能顺利运行
而把它用于webServices就会报错,错误信息为:
未处理的“System.Web.Services.Protocols.SoapException”类型的异常出现在 system.windows.forms.dll 中。其他信息: System.Web.Services.Protocols.SoapException: 服务器无法处理请求。 ---> System.Data.SqlClient.SqlException: 用户 'ALISTAIR\ASPNET' 登录失败。public bool IsExist(string text)
{
  SqlDataReader sqlReader = null;
  SqlConnection sqlconn = new SqlConnection
    ("server = (local);Integrated Security = SSPI;database = E-Test");
  SqlCommand sqlcomm = new SqlCommand
    ("select ID, password from students", sqlconn);
    try
    {
    sqlconn.Open();
    sqlReader = sqlcomm.ExecuteReader();
      while(sqlReader.Read())
      {
        if(text == sqlReader["ID"].ToString())
        {
             return true;
         }
       }
       return false;
    }
    finally
    {
      if(sqlReader != null)
      {
        sqlReader.Close();
      }
      if(sqlconn.State == ConnectionState.Open)
      {
        sqlconn.Close();
       }
         }
}
为什么在winform下运行上面程序,就能顺利运行
而把它用于webServices就会报错,错误信息为:
未处理的“System.Web.Services.Protocols.SoapException”类型的异常出现在 system.windows.forms.dll 中。其他信息: System.Web.Services.Protocols.SoapException: 服务器无法处理请求。 ---> System.Data.SqlClient.SqlException: 用户 'ALISTAIR\ASPNET' 登录失败。希望大家帮帮忙!