请问各位大侠,这个问题该怎样解决? 下面是asp.net采用三层架构 web.config配置文件 10
<addname="ConnectionString"connectionString="DataSource=.\SQLEXPRESS;AttachDbFilename...
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\xinwen.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
下面是出现错误的代码
public int checkLogin(string loginName, string loginPwd) {
SqlConnection myConn = Getconnection(); SqlCommand myCmd = new SqlCommand("select count(*) from User where admin=@loginName and password =@loginPwd,myConn"); myCmd.Parameters.Add(new SqlParameter("@loginName", SqlDbType.VarChar, 20)); myCmd.Parameters["@loginName"].Value = loginName; myCmd.Parameters.Add(new SqlParameter("@loginPwd", SqlDbType.VarChar, 50)); myCmd.Parameters["@loginPwd"].Value = loginPwd; myConn.Open(); int i = (int)myCmd.ExecuteScalar(); myCmd.Dispose(); myConn.Close(); return i; }
错误类型
谁能帮忙解决一下!感谢了! 展开
下面是出现错误的代码
public int checkLogin(string loginName, string loginPwd) {
SqlConnection myConn = Getconnection(); SqlCommand myCmd = new SqlCommand("select count(*) from User where admin=@loginName and password =@loginPwd,myConn"); myCmd.Parameters.Add(new SqlParameter("@loginName", SqlDbType.VarChar, 20)); myCmd.Parameters["@loginName"].Value = loginName; myCmd.Parameters.Add(new SqlParameter("@loginPwd", SqlDbType.VarChar, 50)); myCmd.Parameters["@loginPwd"].Value = loginPwd; myConn.Open(); int i = (int)myCmd.ExecuteScalar(); myCmd.Dispose(); myConn.Close(); return i; }
错误类型
谁能帮忙解决一下!感谢了! 展开
3个回答
展开全部
SqlCommand myCmd = new SqlCommand("select count(*) from User where admin=@loginName and password =@loginPwd,myConn");
上面的语句你最后一个双引号标错位置了
应改为
SqlCommand myCmd = new SqlCommand("select count(*) from User where admin=@loginName and password =@loginPwd",myConn);
上面的语句你最后一个双引号标错位置了
应改为
SqlCommand myCmd = new SqlCommand("select count(*) from User where admin=@loginName and password =@loginPwd",myConn);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询