I noticed that every time i focused something else instead of the text boxes i was editing, my update worked, so if i do this:
txtAtual.Focus();
this.BindingContext[ds.Tables[0]].EndCurrentEdit();
foreach(DataTable dt in ds.Tables) {
foreach(DataRow dr in dt.Rows) {
dr.EndEdit();
}
}
try {
da.Update(ds.Tables[0]);
} catch (Exception ex) {
MessageBox.Show (ex.ToString());
}
If i take off the first line, with the txtAtual.focus(), my updated doesnt work, simply chaging the focus to this text box (that doesnt have any DataBindings) all the updates work.
Anyone knows why this can be happening?
thanx in advance.
On 5/2/06, Fabio Gomes <[EMAIL PROTECTED]
> wrote:
I m trying to do make a simple UPDATE using this:
this.BindingContext[ds.Tables[0]].EndCurrentEdit();
da.Update(ds.Tables[0]);
My BindingContext is working fine and i can navigate trough the records, but when i try to update my data into the database nothing happens!
This is my code:
try {
this.BindingContext[ds.Tables[0]].EndCurrentEdit();
da.Update(ds,ds.Tables[0].TableName);
} catch (Exception ex) {
MessageBox.Show(ex.ToString());
}
I even tried this:
cmdUpdate.Parameters.Add("@CLI_COD", FbDbType.Integer);
cmdUpdate.Parameters.Add ("@CLI_NOME", FbDbType.VarChar);
cmdUpdate.Parameters.Add("@CLI_SOBRENOME", FbDbType.VarChar);
And i tried to write the query in this way:
UPDATE CLIENTES SET CLI_NOME= ?, CLI_SOBRENOME = ? WHERE CLI_COD = ?
And this way:
UPDATE CLIENTES SET CLI_NOME= @CLI_NOME, CLI_SOBRENOME = @CLI_SOBRENOME WHERE CLI_COD = @CLI_COD
What is pissing me off, is that i dont get ANY erros.
And the problem isnt the connection, i tried: cn.Open() before the da.Update, and it gave me an error: Connection already opened.
What is wrong with this?
Thanx in advance for any help.