如何使用c#

时间:2016-10-25 12:05:10

标签: c# c#-4.0

大家好,我有Access数据库,上面有一些数据,ID是自动编号ex ID 17,以及名称电话号码ex:222下的列,所以我现在要输入另一个电话号码到同一列电话号码因为这个人有两个电话号码

OleDbCommand cmd = new OleDbCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "insert into data ( [Phone number] ) values ('" + textBox3.Text + "') WHERE [ID] like  '" + textBox15.Text + "'  ";
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
System.Windows.Forms.MessageBox.Show("Data Inserted Successfully");
con.Close();

1 个答案:

答案 0 :(得分:0)

OleDbCommand cmd = new OleDbCommand();                      cmd.CommandType = CommandType.Text;                      cmd.CommandText ="插入[data]([Date],[Name])值('" + textBox1.Text +"',' " + textBox2.Text +"')&#34 ;;                      cmd.Connection = con;                      con.Open();                      cmd.ExecuteNonQuery();                      System.Windows.Forms.MessageBox.Show("数据已成功插入");                      con.Close();