Nel

Nel

  • 1.2k
  • 716
  • 991.8k

INSERT INTO doesn't insert data in the database

Sep 12 2013 4:45 AM

Hi,

I have  this code for inserting data in the MS ACCESS database:
 command.CommandText = "Insert into PSOSTD ([SMAT11], [SKOM], [KOL], [CEN], [BRP], [DOK],[DATA], [SERBR1], [SERBR2], [MBRK], [IN]) values (?,?,?,?,?,?,?,?,?,?,?)";
  
  command.Parameters.AddWithValue("@SMAT11", comboBox1.Text);
  command.Parameters.AddWithValue("@SKOM", comboBox3.Text);
  command.Parameters.AddWithValue("@KOL", Convert.ToInt32(textBox4.Text));
  command.Parameters.AddWithValue("@CEN", Convert.ToInt32(label15.Text));
  command.Parameters.AddWithValue("@BRP", textBox1.Text);
  command.Parameters.AddWithValue("@DOK", "4");
  command.Parameters.AddWithValue("@DATA", dateTimePicker1.Value.Date);
  command.Parameters.AddWithValue("@SERBR1", "");
  command.Parameters.AddWithValue("@SERBR2", "");
  command.Parameters.AddWithValue("@MBRK", comboBox2.SelectedItem);
 if (radioButton1.Checked)
  {
  command.Parameters.AddWithValue("@IN", "J");
  }
  else if (radioButton2.Checked)
  {
  command.Parameters.AddWithValue("@IN", "A");
  }
  else
  {
  MessageBox.Show("Nemate izbrano dali kontrolorot e od JSP ili od agencija");
  comboBox2.Focus();
  }
 
 
  DataSet1 dset = new DataSet1();
  conn.Open();
  command.ExecuteNonQuery();
conn.Close();

When debugging, I don't get any error, but it doesn't insert data in the database.
Can anybody help me please?
Thanks

Answers (6)