登陆的页面能预览,但登陆正确后后,为何不能跳转呢?
代码如下:
SqlCommand cmd = new SqlCommand("select count(id) from userinfo where username= @username and
[password] = @password", conn);
cmd.Parameters.AddWithValue("@username", TextBoxUid.Text);
cmd.Parameters.AddWithValue("@password", TextBoxPwd.Text);
conn.Open(); int iCount=Convert.ToInt32(cmd.ExecuteScalar());
if (iCount > 0)
{ Response.Redirect("index.aspx"); }
else
{
LabelErrMsg.Text = "error.aspx";
}
代码如下:
SqlCommand cmd = new SqlCommand("select count(id) from userinfo where username= @username and
[password] = @password", conn);
cmd.Parameters.AddWithValue("@username", TextBoxUid.Text);
cmd.Parameters.AddWithValue("@password", TextBoxPwd.Text);
conn.Open(); int iCount=Convert.ToInt32(cmd.ExecuteScalar());
if (iCount > 0)
{ Response.Redirect("index.aspx"); }
else
{
LabelErrMsg.Text = "error.aspx";
}
解决方案 »
- 导入excel时验证数据是否有重复
- Firefox播放中文WMV文件问题,吐血放分
- JTBCEIDT这个编辑器,有人用过么?怎么在.NET下面使用啊?
- 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
- 关于Active Directory的问题,求救大家
- 在线等!!!!大家帮忙!
- 调用显示日期的javascript脚本,却弹出了一个AD的动画
- 请问如何让div的display状态在postback后还能够保持?
- 用孟大哥的方法做的在datagrid显示图片的例子的问题
- 关于水印图片的问题!!在线等!!!
- 在FCKeditor中如何设置弹出窗口的的字体和让它显示中文
- 为什么在IE浏览无法显示ASP.NET控件?
[password] = @password", conn);
"select * from userinfo where username= @username and [password] = @password"
你的条件要的那么具体查出的一定是一条记录
第1就用×去查就行了
第2 int iCount=cmd.ExecuteNonQuery();
就好了再跟就去看看
try
{
Response.Redirect("default.aspx");
}
catch(Exception error)
{
Response.Write(error.Message);
}楼主试下上面的代码
Response.Redirect
不能放置于try catch 语句中
至少一般情况下不可以这样。所以我怀疑楼主的Response.Redirect是不是在 try catch 中