简单易懂方便coppy
}
if (flagRegister == true) //确认用户注册后,把用户写入数据库
{
SqlConnection conConnection = new SqlConnection(strConnect);
conConnection.Open();
string cmd = "insert into 用户(用户名,密码,email) values ('" + textBox1.Text + "'," + "'" + textBox2.Text + "'," + "'" + textBox3.Text + "') ";
SqlCommand com = new SqlCommand(cmd, conConnection);
com.ExecuteNonQuery();
conConnection.Close();
MessageBox.Show("注册成功!点击确定,返回登录界面。", "提示");
this.Close();
Form1 f1 = new Form1();
http://www.77cn.com.cnbel2.Text = "欢迎你," + textBox1.Text;
http://www.77cn.com.cnbel1.Visible = false;
http://www.77cn.com.cnbel3.Visible = false;
f1.linkLabel1.Visible = false;
f1.linkLabel2.Visible = false;
http://www.77cn.com.cnbel2.Visible = true;
f1.Show();
}
}
public bool UserFlag; //定义标志位,来确认用户是否存在
private void textBox1_TextChanged(object sender, EventArgs e)
{
SqlConnection conConnection = new SqlConnection(strConnect);
conConnection.Open();
string cmd = "select 用户名 from 用户";
SqlCommand com = new SqlCommand(cmd, conConnection);
SqlDataReader readerUser = com.ExecuteReader();
while (readerUser.Read())
{
if (textBox1.Text == readerUser["用户名"].ToString().Trim())
{
label5.Text = "用户已存在,请重新输入!";
UserFlag = true;
//textBox1.Text = "";
return;
}
else if (textBox1.Text != readerUser["用户名"].ToString().Trim())
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库源码C#登录注册小程序源码(3)在线全文阅读。
相关推荐: