删除
this.sqlDeleteCommand1.CommandText="delete from 学生信息表 where 姓名='"+this.textBox1.Text.Trim()+"'or 学号='"+this.textBox2.Text.Trim()+"'or 专业='"+this.textBox3.Text.Trim()+"'";
this.sqlDeleteCommand1.Connection.Open();
this.sqlDeleteCommand1.ExecuteNonQuery();
this.dataSet11.Clear();
this.sqlDataAdapter1.Fill(this.dataSet11);
this.sqlDeleteCommand1.Connection.Close();
this.textBox1.Text="";this.textBox2.Text="";
this.textBox3.Text="";
查询
this.sqlSelectCommand1.CommandText="select * from 学生信息表where 姓名='"+this.textBox1.Text.Trim()+"'";(姓名为主键)
this.sqlConnection1.Open();
this.sqlSelectCommand1.ExecuteNonQuery();
this.dataSet11.Clear();
this.sqlDataAdapter1.Fill(this.dataSet11);
this.dataGrid1.DataSource=this.dataSet11;
this.sqlSelectCommand1.Connection.Close();
if(this.dataSet11.Tables[0].Rows.Count>0)
{
MessageBox.Show("查找成功!","系统提示。",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
else
{
MessageBox.Show("查找不成功!","系统提示。",MessageBoxButtons.OK,MessageBoxIcon.Information);
}