wd.Text.Trim() == txtUserPwdAgain.Text.Trim()) { // 创建连接数据库的对象 SqlConnection conn = new SqlConnection ( ConfigurationManager .ConnectionStrings[ "connectionstring" ].ConnectionSt ring); conn.Open(); // 打开数据库连接 mand cmd = new mand ( "insert into UserTable (UserName,UserPwd,Email,PhoneNumber) Values('" + txtUserName.Text.Trim() + "','" + txtUserPwd.Text.Trim() + "','" + txtEmail.Text.Trim() + "','" + txtPhoneNumber.Text.Trim() + "')" , conn); int i= cmd.ExecuteNonQuery(); if (i == 1) { mand cmd1 = new mand ( "select MAX(UserNumber) from UserTable" , conn); // 执行命令对象操作的查询操作,并将结果返回给 DataReader 对象。 SqlDataReader id= cmd1.ExecuteReader(); // 执行 DataReader 的 Read 方法,判断是否查询到记录 if (id.Read()) { Response.Write( "<script>alert(' 注册成功! 您的帐号为'+'" + id[0] + "');location.href='login.aspx'</script>" ); }}