首页上一页 1 下一页尾页 1 条记录 1/1页
ASP.NET从入门到精通测试中出现----对象名tb_User无效
发表在ASP.NET图书答疑
2008-11-09
是否精华
是
否
版块置顶:
是
否
[font color=#00FF00]在后台登陆中发现对象名tb_User无效,代码如下:
public int checkLogin(string loginName, string loginPwd)
{
SqlConnection myConn = GetConnection();
SqlCommand myCmd = new SqlCommand("select count(*) from tb_User where Name=@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();
[font color=#FF0000]int i = (int)myCmd.ExecuteScalar();[/font]
myCmd.Dispose();
myConn.Close();
return i;[/font]
请指导一下
谢谢
public int checkLogin(string loginName, string loginPwd)
{
SqlConnection myConn = GetConnection();
SqlCommand myCmd = new SqlCommand("select count(*) from tb_User where Name=@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();
[font color=#FF0000]int i = (int)myCmd.ExecuteScalar();[/font]
myCmd.Dispose();
myConn.Close();
return i;[/font]
请指导一下
谢谢