try
{
sqlconn = new SqlConnection(ConfigurationManager.ConnectionStrings["addressconn"].ConnectionString);
sqlconn.Open();
cmd = new SqlCommand("select username,userpassw from userinfo where username=@name and userpassw=@userpassw", sqlconn);
//cmd.CommandText = "select username from userinfo where username=@name";
cmd.Parameters.Add("@name", SqlDbType.VarChar, 20).Value = texaccount.Text.Trim();
cmd.Parameters.Add("@userpassw", SqlDbType.VarChar, 100).Value = txt_pwd.Text.Trim();
//cmd.Parameters["@name"].Value = txtName.Text.Trim();
if (cmd.ExecuteScalar() == null)
Response.Write("<script language=javascript>alert('登录失败');</script>");
else
{
Session["username"] = texaccount.Text.Trim();
Session["userpwd"] = txt_pwd.Text.Trim();
Session["state"] = true;
try
{
Response.Redirect("Default.aspx",false );
}
catch (System.Threading.ThreadAbortException ei)
{
throw;
}
}
}
catch
{
Response.Write("<script language=javascript>alert('登录失败');</script>");
//sqlconn.Close(); }
finally
{
if (sqlconn.State == ConnectionState.Open)
sqlconn.Close();
}
}
在网上查了一下,发现改了Response.Redirect("Default.aspx",false );
还是不能跳转啊,虽然是没有了异常。在线等着救命啊!!!
{
sqlconn = new SqlConnection(ConfigurationManager.ConnectionStrings["addressconn"].ConnectionString);
sqlconn.Open();
cmd = new SqlCommand("select username,userpassw from userinfo where username=@name and userpassw=@userpassw", sqlconn);
//cmd.CommandText = "select username from userinfo where username=@name";
cmd.Parameters.Add("@name", SqlDbType.VarChar, 20).Value = texaccount.Text.Trim();
cmd.Parameters.Add("@userpassw", SqlDbType.VarChar, 100).Value = txt_pwd.Text.Trim();
//cmd.Parameters["@name"].Value = txtName.Text.Trim();
if (cmd.ExecuteScalar() == null)
Response.Write("<script language=javascript>alert('登录失败');</script>");
else
{
Session["username"] = texaccount.Text.Trim();
Session["userpwd"] = txt_pwd.Text.Trim();
Session["state"] = true;
try
{
Response.Redirect("Default.aspx",false );
}
catch (System.Threading.ThreadAbortException ei)
{
throw;
}
}
}
catch
{
Response.Write("<script language=javascript>alert('登录失败');</script>");
//sqlconn.Close(); }
finally
{
if (sqlconn.State == ConnectionState.Open)
sqlconn.Close();
}
}
在网上查了一下,发现改了Response.Redirect("Default.aspx",false );
还是不能跳转啊,虽然是没有了异常。在线等着救命啊!!!
解决方案 »
- 读取XML中某个节点的值,为什么是空啊?!
- 托盘上点击显示窗体,窗体怎么总是最小化的?
- 关于音视频捕捉编辑的问题,求高手帮忙!!!
- 问一个关于CheckBoxList和javascrit 取值
- 散分100:到哪里可以下载.net2005简体中文企业版
- 多表查询问题
- 请求各位高手指点指点,踊跃发言,多给点意见!跪谢。。。。
- 各位哪有类似msn的软件的开发例程?
- 哪位大哥推荐一本C#的入门书,别太厚
- !!!清帮我解决这个怪问题! 500分相送 !!!!!!!
- WIN7 上默认UAC情况下 C#以(AsInvoke请求权限)操作XML文件的问题 XML用IE和记事本打开结果不一致
- 如何定义全局错误页面
Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('登录失败');window.location='Default.aspx';", true);好使。好像都不行喔,很无语啊
ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>alert(\'登录失败!\');setTimeout(function(){location.href='Default.aspx'},1000); </script>");