检测到无法访问的代码
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的下面
}
哪位能给出解决方案啊????????
------解决方案--------------------既然两个return相同,那么就可以把return放到最后strcon.Close();的下边。
------解决方案-------------------- if (count > 0)
{
Response.Write("<script>alert('用户已经注册,请您重新输入!');history.back()</script>");
}
else
{
Response.Write("<script>alert('您可以使用此用户进行注册!');history.back()</script>");
}
strcon.Close();
return;