找到一个用户注册的源码 麻烦各位老大给解释一下
AddUser.cs
public class AddUser{ SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dbuser"].ConnectionString); public AddUser() { // // TODO: 在此处添加构造函数逻辑 // } public bool AddUserS(String name, String pass) { String T_name = name; String T_pass = pass; String sql = "insert into info values('" + T_name + "','" + T_pass + "')"; SqlCommand cmd = new SqlCommand(sql, con); int Result = -1; try { con.Open(); Result = cmd.ExecuteNonQuery(); if (Result != -1) { return true; } else { return false; } } catch (Exception ex) { throw (ex); } finally { con.Close(); } return false; }}
public partial class DisposeEvent : System.Web.UI.Page{ CheckUser cu = new CheckUser(); AddUser au = new AddUser(); logon go = new logon(); protected void Page_Load(object sender, EventArgs e) { switch (Request.QueryString["Event"]) { case "Reg": if (au.AddUserS(Request.QueryString["Name"].ToString(), Request.QueryString["Pass"].ToString())) { Response.Write("true"); Response.End(); } else { Response.Write("false"); Response.End(); } break;