By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,509 Members | 1,293 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,509 IT Pros & Developers. It's quick & easy.

Binded text fields don't update the database

P: n/a
Hi there,

I will post my question to this group too bacause the .data group seems
to be rather quiet.

I've been playing with VB.NET and ADO for a week now and find the
different data handling functions very easy and nice. Anyway, I'm afraid
that I haven't understood the data binding things correct.

I'm using MySQL Connector/.NET to access my database from the
application. The queries work find and I'm able to fill the dataset from
data adapter to access the data.

I've binded a few text fields to the dataset in the code (I don't want
to use the Server Explorer).
Me.txtID.DataBindings.Clear()
Me.txtID.DataBindings.Add("Text", dDataset, "table.id")

For debug purposes, I've connected also a DataGrid to the dataset:
Me.DataGrid1.DataSource = dDataset

I fetch a row from the database by SELECT * FROM table WHERE
name="Ville". No problems with getting the correct values to the
textboxes. But now I try to edit the data.

I understood that since a textbox is binded to a dataset, changes made
to the textbox content will update the dataset automatically. OK, it
seems to do that correctly. I edit a textbox, the column content changes
in a datagrid as it should. Now I try to update the database with my
changes:
dAdapter.Update(dDataset, "table")

For some reason, the changes won't reach the database at all. Anyway, no
exception is thrown either.

If I edit the same field value in a datagrid and then call the update of
the data adapter, the modified data will be updated to the databse
without any problems.

Any ideeas?

Thanks for your help!

Ville
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Ville,

Mostly is the answer to put before the update the sentence

BindingContext(ds.Tables(0)).EndCurrentEdit()

The data is pushed down in the datasource by a rowchange, and with that
command above is that forced.

When you are searching for a good ADONET newsgroup than it the newsgroup

microsoft.public.dotnet.framework.adonet
the one you are looking for

Adonet
news://msnews.microsoft.com/microsof...amework.adonet

Web interface:
http://communities2.microsoft.com/co...amework.adonet

I hope this helps?

Cor
"Ville Mattila" <vi***@mattila.fi>
Hi there,

I will post my question to this group too bacause the .data group seems to
be rather quiet.

I've been playing with VB.NET and ADO for a week now and find the
different data handling functions very easy and nice. Anyway, I'm afraid
that I haven't understood the data binding things correct.

I'm using MySQL Connector/.NET to access my database from the
application. The queries work find and I'm able to fill the dataset from
data adapter to access the data.

I've binded a few text fields to the dataset in the code (I don't want
to use the Server Explorer).
Me.txtID.DataBindings.Clear()
Me.txtID.DataBindings.Add("Text", dDataset, "table.id")

For debug purposes, I've connected also a DataGrid to the dataset:
Me.DataGrid1.DataSource = dDataset

I fetch a row from the database by SELECT * FROM table WHERE
name="Ville". No problems with getting the correct values to the
textboxes. But now I try to edit the data.

I understood that since a textbox is binded to a dataset, changes made
to the textbox content will update the dataset automatically. OK, it
seems to do that correctly. I edit a textbox, the column content changes
in a datagrid as it should. Now I try to update the database with my
changes:
dAdapter.Update(dDataset, "table")

For some reason, the changes won't reach the database at all. Anyway, no
exception is thrown either.

If I edit the same field value in a datagrid and then call the update of
the data adapter, the modified data will be updated to the databse
without any problems.

Any ideeas?

Thanks for your help!

Ville

Nov 21 '05 #2

P: n/a
Cor Ligthert wrote:
Mostly is the answer to put before the update the sentence

BindingContext(ds.Tables(0)).EndCurrentEdit()
Thank you Cor! I added that row to the code and the data was correctly
updated.
When you are searching for a good ADONET newsgroup than it the newsgroup

microsoft.public.dotnet.framework.adonet
the one you are looking for


Thanks for a tip too. I will subscribe there and follow the discussion
for future questions.

Best regards,
Ville
Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.