深圳网站建设公司_深圳营销型网站_西安seo_海淀网站建设

杭州网站建设公司

阳江网站制作公司、莱芜网站优化、永久使用、不限域名、随州网站建设公司

最好的自助建站系统?

深圳网站建设公司_深圳营销型网站_西安seo_海淀网站建设

{public partial class Register : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e){UnobtrusiveValidationMode = UnobtrusiveValidationMode.None;}public string connStr = ConfigurationManager.ConnectionStrings["NewsConnectionString"].ConnectionString;protected void Button1_Click(object sender, EventArgs e){//获取登录名和密码信息String strLoginID = txtAdmin.Text;String strLoginPwd = txtPwd.Text;String strLoginName = txtName.Text;//访问数据库Newsuser表,注册信息//第一步建立连接对象connSqlConnection conn = new SqlConnection(connStr);//设置SQL查询语句string sql = "insert into [Newsuser](UserID,UserPassword,UserName) values('" + strLoginID + "','" + strLoginPwd + "','" + strLoginName +"')";//创建sqlCommand对象SqlCommand cmd = new SqlCommand();//打开conn连接对象conn.Open();if(check(strLoginID, cmd)){cmd.Connection = conn;cmd.CommandText = sql;//建dr存储ExecuteNonQuery结果,用于判断SQL语句执行的结果int dr = cmd.ExecuteNonQuery();if (dr > 0) //如果有数据,则dr.Read()为true{//注册成功Response.Write("<script>alert('注册成功!');</script>");//注册成功后跳转Response.Redirect("Login.aspx");}else{//alert()弹窗函数Response.Write("<script>alert('注册失败!');</script>");}}else{Response.Write("<script>alert('用户名已存在!');</script>");}}protected bool check(string u, SqlCommand cmd){//建立连接对象connSqlConnection conn1 = new SqlConnection(connStr);//设置SQL查询语句string sql1 = "select * from Newsuser where UserID='" + u + "'";//打开conn连接对象conn1.Open();cmd.Connection = conn1;cmd.CommandText = sql1;//利用SqlCommand对象,创建SqlDataReader对象,用于判断SQL语句执行的结果SqlDataReader dr = cmd.ExecuteReader();if (dr.Read()) //如果有数据,则dr.Read()为true{return false;}else{return true;}}} 高端网站设计制作软件开发技术方案邢台网站推广威海网站制作天蝎网站建设网站推广建站西安seo优化滁州seo开发公众号网站建设方案书网站开发需要多少钱徐州建网站长沙专业做网站公司网站制作有哪些网站建设一条龙泰安网站优化赣州网站优化深圳网站制作的公司台州网站优化三明seo苏州网站建设推广服务公司网站制作网站设计报告网站建设模板西安企业建站小程序开发价格宝安做网站的福田做网站的公司的建站公司深圳软件开发android软件开发

猜你喜欢