1、 /数据库连接,验证用户名和密码string testConnectionstring = “Data Source=(local);Initial Catalog=MyQQuser;Integrated Security=sspi“;SqlConnection con = new SqlConnection(testConnectionstring);string sql = “select Name,Password,Cname from QQuser“;SqlCommand com = new SqlCommand(sql, con); SqlDataAdapter da = new S
2、qlDataAdapter();da.SelectCommand = com;con.Open();DataSet ds = new DataSet();da.Fill(ds, “QQuser“);DataRow nameRow;if (comboBox1.Text != “)if (textBox1.Text != “)for (int i = 0; i ds.Tables“QQuser“.Rows.Count; i+)nameRow = ds.Tables“QQuser“.Rowsi;if (nameRow0.ToString().Trim() = comboBox1.Text.ToStr
3、ing().Trim() SqlCommand comaaa = new SqlCommand(sqlaaa, con);comaaa.ExecuteNonQuery();/数据修改Form2 main = new Form2();main.lb.Text=boBox1.Text.ToString();main.lbname.Text = nameRow2.ToString(); ;main.Show();main.Text = “欢迎你:“ + nameRow2.ToString();/把数据库里的数据提取出来main.name.Text = nameRow2.ToString();main
4、.notifyIcon1.Text = nameRow2.ToString() + boBox1.Text;con.Close();main.Show();this.Hide();return;con.Close();/MessageBox.Show(“用户名或密码不正确“);if (MessageBox.Show(“用户名或密码不正确“,“错误“,MessageBoxButtons.OK,MessageBoxIcon.Error ) = DialogResult.OK)textBox1.Text = “;else MessageBox.Show(“请输入密码!“);else MessageBox.Show(“请输入账号和密码!“,“提示“,MessageBoxButtons.OK,MessageBoxIcon.Asterisk);