0

I am trying to add a row to a table in the database using the table adapter's update method. I am not getting any errors. It looks like it is working fine, but there is no actual insertion into the database. However, if I try to insert the same row again I get a constraint exception saying that I am trying to insert a data that is already in the table. But in the end there is no data physically inserted into the table. I tried to use table adapter's insert method but I got the same error.

Where am I doing wrong?

Here is the code where insertion is made:(database name: pompadatabase, table name: pompa)

pompadatabaseDataSet.pompaRow tmprow;
tmprow = pompadatabaseDataSet.pompa.NewpompaRow();
tmprow.isim = textBox5.Text;
tmprow.info = richTextBox1.Text;
tmprow.resim = bao;
tmprow.seri_id = Convert.ToInt32(sinifBox.SelectedValue.ToString());
this.pompadatabaseDataSet.pompa.Rows.Add(tmprow);
this.pompaTableAdapter.Update(this.pompadatabaseDataSet.pompa);

2 Answers 2

3

Where are you "physically" looking for the data ? i mean, are you checking upon the db instance you have in your solution explorer or in the one inside the debug folder ? When you run your application, a copy of the SQL Server CE db file will be put inside that folder and the rows will be saved there. Each time you re-run your application, that file will be overwritten. Try to run your application from that folder, if everything goes well, that was the problem. Well it could sound silly but it happened to me when i first started to work with DataSets and TableAdapters.

Sign up to request clarification or add additional context in comments.

Comments

-1

the transaction of pompaTableAdapter needs to b commited. i.e urtransaction.Commit(); then look in Db ur data wud be saved.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.