【ADO.NET基础-Regidter】简单的账户注册界面和源代码(可用于简单面试基础学习用)
2021-07-02 18:07
阅读:703
YPE html>
标签:nic return load bytes static .net body 建议 cat
在阅读时如有问题或者建议,欢迎指出和提问,我也是初学者.........
前台代码:
"http://www.w3.org/1999/xhtml">"server">"center">用户登录页面
后台代码:
using System; using System.Data.SqlClient; using System.Data; using System.Configuration; using System.Drawing; using System.Text; using System.Security.Cryptography; namespace ado.netDemo1 { public partial class register : System.Web.UI.Page { SqlConnection connStr = new SqlConnection(ConfigurationManager.ConnectionStrings["connStr"].ToString()); string sql; protected void Page_Load(object sender, EventArgs e) { } protected void btnRegister_Click(object sender, EventArgs e) { if (txtNum.Text.Trim() == "" || txtName.Text.Trim() == "" || txtpwd.Text.Trim() == "") { lblText.ForeColor = Color.Red; lblText.Text = "请将个人信息填写完整!"; } else if (txtNum.Text.Trim() == "" && txtName.Text.Trim() == "" && txtpwd.Text.Trim() == "") { lblText.ForeColor = Color.Red; lblText.Text = "请将个人信息填写完整!"; } else { //加密处理注册Password string hashedpwd=Encrypt(txtpwd.Text.Trim()); sql = "insert into tb_Students(SID,Name,Password)Values(‘" + txtNum.Text.Trim() + "‘,‘" + txtName.Text.Trim() + "‘,‘" + hashedpwd + "‘)"; connStr.Open(); SqlCommand cmd = new SqlCommand(sql, connStr); int i = cmd.ExecuteNonQuery(); if (i == 1) { lblText.ForeColor = Color.Red; lblText.Text = "注册成功!"; Response.Write(@""); } } } public static string Encrypt(string cleanString) { Byte[] clearBytes = new UnicodeEncoding().GetBytes(cleanString); Byte[] hashedBytes = ((HashAlgorithm)CryptoConfig.CreateFromName("MD5")).ComputeHash(clearBytes); return BitConverter.ToString(hashedBytes); } } }
界面截图:
【ADO.NET基础-Regidter】简单的账户注册界面和源代码(可用于简单面试基础学习用)
标签:nic return load bytes static .net body 建议 cat
原文地址:http://www.cnblogs.com/888888CN/p/7127403.html
文章来自:搜素材网的编程语言模块,转载请注明文章出处。
文章标题:【ADO.NET基础-Regidter】简单的账户注册界面和源代码(可用于简单面试基础学习用)
文章链接:http://soscw.com/index.php/essay/100907.html
文章标题:【ADO.NET基础-Regidter】简单的账户注册界面和源代码(可用于简单面试基础学习用)
文章链接:http://soscw.com/index.php/essay/100907.html
评论
亲,登录后才可以留言!