C#.net的简单问题

来源:百度知道 编辑:UC知道 时间:2024/06/27 14:34:51
我刚学c#.net 所以问些简单的问题
我要做一个前台的ASP.NET WEB应用程序 是分层开发 一个界面输入用户名和密码 调用SQL SERVER2000中我已经写好的存储过程 然后在另外一个界面里的DataGrid中显示我查询的该用户的信息 我已经完成的上面的部分 但是如果输入错误的用户名和密码 也是跳转界面 但是界面什么都不显示 我想问一下 如果输入错误的用户名和密码 怎么才能跳转到另外一个页面 提示出错 谢谢了 详细些

SqlConnection con = DB.createConnection();
con.Open();

string userName = Request.Form["UserName"].ToString();
string userPwd = Request.Form.Get("UserPwd").ToString();
SqlCommand cmd = new SqlCommand("select count(*) from [login1].[dbo].[Paw] where UserName='" + userName + "' and UserPwd='" + userPwd + "'", con);
int abc = Convert.ToInt32(cmd.ExecuteScalar());
if (abc > 0)
{
Response.Redirect("index.aspx");
}
else
{
Response.Redirect("另外一个页面");
}

好好看吧

使用Response.Redirect

根据存储过程的返回结果在跳转之前做判断