PC Review


Reply
Thread Tools Rate Thread

Binded text fields don't update the database

 
 
Ville Mattila
Guest
Posts: n/a
 
      18th Nov 2004
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
 
Reply With Quote
 
 
 
 
Cor Ligthert
Guest
Posts: n/a
 
      18th Nov 2004
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" <(E-Mail Removed)>

> 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



 
Reply With Quote
 
Ville Mattila
Guest
Posts: n/a
 
      18th Nov 2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do i import and update to created fields from my ERP database cfaria Microsoft Outlook Contacts 1 21st Aug 2008 03:48 PM
Add new row to binded Dropdownlist retrieved from database table dungdang Microsoft ASP .NET 2 13th Jun 2007 03:27 PM
Code to update fields in backend database Beth Microsoft Access Form Coding 2 26th May 2007 03:00 AM
Displaying a stop watch that is binded to a text box. =?Utf-8?B?QWNjZXNzRGFiYmxlcg==?= Microsoft Access 3 2nd Jun 2006 05:27 PM
List Box Losing Last Line on Binded Data Table Update =?Utf-8?B?Qm9i?= Microsoft C# .NET 0 18th Feb 2004 01:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:51 AM.