qq_22155835
qq_22155835
2015-06-10 12:13

求大神解答!c#+sqlserver简单的注册

  • new
  • comm
  • username
  • sql
            string username = txtUserName.Text;
    string password = txtPwd.Text;
    string connconfig = "server=127.0.0.1;Database=NetworkManagement;uid=sa;pwd=123456";
    SqlConnection conn = new SqlConnection(connconfig);
    conn.Open();
    string sql = "select id from Administrator where username='" + username + "'";
    string sql1 = "insert into Administrator(username,password) values ('" + username + "','" + password + "')";
    SqlCommand comm = new SqlCommand(sql, conn);
    SqlDataReader sdr = comm.ExecuteReader();
    if (sdr["id"]==null)
    {    
        Session["name"] = username;
        SqlCommand comm1 = new SqlCommand(sql1, conn);
        SqlDataReader sdr1 = comm1.ExecuteReader();
        Response.Redirect("default.aspx"); 
    }
    else {
        Response.Redirect("error.aspx");         
    }
    conn.Close();
}
    就是不行啊,怎么办啊
    愁死我了
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答