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 SqlDataAdapter();
修改密码qq 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"].Rows[i];
if (nameRow[0].ToString().Trim() == comboBox1.Text.ToString().Trim() && nameRow[1].ToString().Trim() == textBox1.Text.ToString().Trim())
{
string sqlaaa = "update QQuser set state='在线' where name='" + comboBox1.Text + "'";
SqlCommand comaaa = new SqlCommand(sqlaaa, con);
comaaa.ExecuteNonQuery();
//数据修改
Form2 main = new Form2();
main.lb.Text=thisboBox1.Text.ToString();
main.lbname.Text = nameRow[2].ToString(); ;
main.Show();
main.Text = "欢迎你:" + nameRow[2].ToString();//把数据库里的数据提取出来
main.name.Text = nameRow[2].ToString();
ifyIcon1.Text = nameRow[2].ToString() + thisboBox1.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);
发布评论