protected void check_Click(object sender, EventArgs e)
{
string username = Request["username"];
SqlConnection strcon = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["strcon"]);
strcon.Open();
SqlCommand scd1 = new SqlCommand("select * from rs_User where username='" + username + "'", strcon);
int count = Convert.ToInt32(scd1.ExecuteScalar());
if (count > 0)
{
Response.Write("<script>alert('用户已经注册,请您重新输入!');history.back()</script>");
return;
}
else
{
Response.Write("<script>alert('您可以使用此用户进行注册!');history.back()</script>");
return;
}
strcon.Close();//波浪线出现在strcon的下面
}哪位能给出解决方案啊????????
{
string username = Request["username"];
SqlConnection strcon = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["strcon"]);
strcon.Open();
SqlCommand scd1 = new SqlCommand("select * from rs_User where username='" + username + "'", strcon);
int count = Convert.ToInt32(scd1.ExecuteScalar());
if (count > 0)
{
Response.Write("<script>alert('用户已经注册,请您重新输入!');history.back()</script>");
return;
}
else
{
Response.Write("<script>alert('您可以使用此用户进行注册!');history.back()</script>");
return;
}
strcon.Close();//波浪线出现在strcon的下面
}哪位能给出解决方案啊????????
解决方案 »
- 【请教】asp.net+C#:怎么响应TextBox的回车事件
- 如何在自定义控件中使用第三方控件?
- c#代码高亮 怎么实现
- asp.net WebControls.Button 的样式问题
- 本地可以正常运行,但是上传到服务器显示The type or namespace name 'conn1' could not be found (are yo
- 如何调度COM+对象(有点难度)
- web.config出错
- 以下程序错了哪里???
- 如何把合并行的这段代码改成合并列的
- 解决VS.NET 2003正式版在Windows Server 2003 3790域控制器上不能执行的问题!
- 关于.net中url参数中带&值时获取参数的方法?
- 在QQ注册了企业邮箱,怎么样利用它来发送邮件,看说明要ssi
所以strcon.Close()这句永远执行不了,无论哪个条件成立都执行不到你把 strcon.Close();//波浪线出现在strcon的下面
提到 if (count > 0)前就可以了protected void check_Click(object sender, EventArgs e)
{
string username = Request["username"];
SqlConnection strcon = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["strcon"]);
strcon.Open();
SqlCommand scd1 = new SqlCommand("select * from rs_User where username='" + username + "'", strcon);
int count = Convert.ToInt32(scd1.ExecuteScalar());
strcon.Close();//波浪线出现在strcon的下面 if (count > 0)
{
Response.Write("<script>alert('用户已经注册,请您重新输入!');history.back()</script>");
return;
}
else
{
Response.Write("<script>alert('您可以使用此用户进行注册!');history.back()</script>");
return;
}
}
{
Response.Write("<script>alert('用户已经注册,请您重新输入!');history.back()</script>");
}
else
{
Response.Write("<script>alert('您可以使用此用户进行注册!');history.back()</script>");
}
strcon.Close();
return;