对于高手来说很简单
高手来说问题很简单!
//判断是否有该用户
string StrLog ="select * from Reg where Name='"+UserName+"'";
SqlDataReader Dr;
SqlCommand comm = new SqlCommand(StrLog,conn);
Dr = comm.ExecuteReader();
bool IsUserExit = Dr.Read();
Dr.Close();
//判断密码是否正确
string StrBoth = "select * from Reg where Name='"+ UserName +"'";
StrBoth+="and Pwd='"+Password+"'";
SqlDataReader BothDr;
SqlCommand comm1 = new SqlCommand(StrBoth,conn);
BothDr = comm1.ExecuteReader();
bool IsBothExit = BothDr.Read();
BothDr.Close();
//关闭连接
conn.Close();
//脚本操作
if(!IsUserExit)
{
Response.Write("<script>alert('此用户不存在!')");
return false;
}
if(!IsBothExit)
{
Response.Write("<script>alert('密码错误!')");
return false;
}
else
{
return true;
Response.Write("登录成功!");
}
一段这样的程序,出现错误是:
c:\inetpub\wwwroot\www1\WebForm1.aspx.cs(100): 由于“www1.WebForm1.Button2_Click(object, System.EventArgs)”返回 void,返回关键字后面不得有对象表达式
请问如何改一下就可以搞定,望高手回答,谢谢!