Hi everyone!
i'm using Ying Bai - Practical Database Programming with Visual C#.Net book to built my application(at least some parts of it).
about inserting data to db it says that you can use TableAdapter.Insert method to add data directly to the db. well I did it all like the example said and when I run my application I can see the added data but when I close the application and run it again then the data is not there.
One thing that makes me confused is that it says in the theory part that you need to run executeNonQuery command for this method to work, but in the example code the command is not there and it's suppose to work!
please Help! :)
Am I missing something or missunderstanding?
here's my code:
this is my insert statement built in the tableAdapter via dataset designer, the query is called InsertNewKombiQuery:
INSERT INTO KombiStateTbl(NumberPlate, LicenseExpiryDate, ControlDate, Documentos, FaróisLanternas, EstepeMacacoChaveDeRoda, Triângulo, Extintor, Acendedor, RodasCalota, Retrovisores, Párabrisa, BancosTapetes, Pneus, ParachoqueDianteiro, ParachoqueTraseiro, PortaDianteiraDireitaM, PortaDianteiraEsquerdaP, PortaLateral, LateralEsquerda, LateralEsquerdaTraseira, LateralDireitaTraseira, ParalamaTraseiroDireito, ParalamaTraseiroEsquerdo, Teto, PortaDoPortaMalas, PortaTraseiraDoMotor, Traseira, Dianteira, FaróisDianteiros, FaroisTraseiros, CurrentPic, CurrentPicPath) VALUES (@Param1,@Param2,@Param3, 'OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'OK', NULL, NULL);
and code in my form:
private void okButton_Click(object sender, EventArgs e)
int intInsert = 0;
intInsert = kombiStateTblTableAdapter.InsertNewKombiQuery(noPlateTextBox.Text,
licenseDateTimePicker.Value.Date, controlDateTimePicker.Value.Date);
if (intInsert != 0)
{
MessageBox.Show("The data insertion is successful", "Success", MessageBoxButtons.OK,
MessageBoxIcon.Information);
noPlateTextBox.Text = "";
okButton.Enabled = false;
this.Close();
}
else
{
MessageBox.Show("The data insertion is failed", "Error", MessageBoxButtons.RetryCancel,
MessageBoxIcon.Error);
}
}
{