哪位有实例或者代码的发给我看看,谢谢了
private void button2_Click(object sender, System.EventArgs e)
{
this.sqlInsertCommand2.Parameters["@Id"].Value=textBox1.Text;
this.sqlInsertCommand2.Parameters["@name"].Value=textBox2.Text;
this.sqlInsertCommand2.Parameters["@Sex"].Value=textBox3.Text;
this.sqlInsertCommand2.Parameters["@Age"].Value=textBox4.Text;
this.sqlInsertCommand2.Parameters["@Telephone"].Value=textBox5.Text;
this.sqlInsertCommand2.Parameters["@Code"].Value=textBox6.Text;
this.sqlInsertCommand2.Connection.Open();
this.sqlInsertCommand2.ExecuteNonQuery();
this.sqlInsertCommand2.Connection.Close();
this.sqlConnection1.Open();
this.sqlDataAdapter2.Fill(this.dataSet11);
this.sqlConnection1.Close();
this.dataGrid1.Update();
this.dataGrid1.Refresh();
this.textBox1.Text="";this.textBox2.Text="";
this.textBox3.Text="";this.textBox4.Text="";
this.textBox5.Text="";this.textBox6.Text="";
}
private void button1_Click(object sender, System.EventArgs e)
{
this.sqlDeleteCommand3.CommandText="delete from 表名where Id='"+this.textBox12.Text.Trim()+"'or Name='"+this.textBox11.Text.Trim()+"'or Sex='"+this.textBox10.Text.Trim()+"'or Age='"+this.textBox9.Text.Trim()+"'or Telephone='"+this.textBox8.Text.Trim()+"'or Code='"+this.textBox7.Text.Trim()+"'";
this.sqlDeleteCommand3.Connection.Open();
this.sqlDeleteCommand3.ExecuteNonQuery();
this.dataSet11.Clear();
this.sqlDataAdapter1.Fill(this.dataSet11);
this.sqlDeleteCommand3.Connection.Close();
this.textBox12.Text="";this.textBox11.Text="";
this.textBox10.Text="";this.textBox9.Text="";
this.textBox8.Text="";this.textBox7.Text="";
}
private void button3_Click(object sender, System.EventArgs e)
{
if(radioButton1.Checked==true)
{
this.sqlSelectCommand3.CommandText="select * from 表名 where Id='"+this.textBox13.Text.Trim()+"'";
}
else if(radioButton2.Checked==true)
{
this.sqlSelectCommand3.CommandText="select * from 表名 where Name='"+this.textBox13.Text.Trim()+"'";
}
this.sqlConnection1.Open();
this.sqlSelectCommand3.ExecuteNonQuery();
this.dataSet11.Clear();
this.sqlDataAdapter3.Fill(this.dataSet11);
this.dataGrid1.DataSource=this.dataSet11;
this.sqlSelectCommand3.Connection.Close();
if(this.dataSet11.Tables[0].Rows.Count>0)
{
MessageBox.Show("查找成功!","系统提示。",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
else
{
MessageBox.Show("查找不成功!","系统提示。",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
this.textBox13.Text="";
}
private void button4_Click(object sender, System.EventArgs e)
{
myBind.Position=0;
}
private void button7_Click(object sender, System.EventArgs e)
{
myBind.Position=myBind.Count-1;
}
private void button5_Click(object sender, System.EventArgs e)
{
if(this.myBind.Position==0)
{
MessageBox.Show("已经是第一条记录了","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
else
{
myBind.Position=myBind.Position-1;
}
}
private void button6_Click(object sender, System.EventArgs e)
{
if(myBind.Position==myBind.Count-1)
{
MessageBox.Show("已经是最后一条记录了","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
else
{
this.myBind.Position=this.myBind .Position +1;
}
}