473,287 Members | 1,570 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Binded text fields don't update the database

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
2 2292
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Jason | last post by:
Let's say I have an html form with 20 or 30 fields in it. The form submits the fields via POST to a php page which updates a table in a database with the $_POST vars. Which makes more sense? ...
16
by: Michael Walton | last post by:
I am trying to write some code that inserts or updates a text field in my SQL Server 2000 database. The SQL statement is created using a submit from a form, and the text is coming from a...
2
by: SammyBar | last post by:
Hi, I'm trying to bind a custom collection class to a data grid, following the guidelines from the article http://msdn.microsoft.com/msdnmag/issues/05/08/CollectionsandDataBinding/default.aspx....
9
by: Pam Ammond | last post by:
I need the code to update the database when Save is clicked and a text field has changed. This should be very easy since I used Microsoft's wizards for the OleDBAdapter and OleDBConnection, and...
0
by: Nithin | last post by:
My code as an txt attachment. I have 2 drop down list boxes that on selection populate text boxes from my database table. I am able to display the correct values in these text boxes. I have 2...
4
by: enrique | last post by:
Hi, I apologize for a newbie question, but my books/research have yielded me no examples and my time is now short. I simply want to update data from text boxes (fields). I'm not using a datagrid...
3
by: Frustrated Developer via DotNetMonster.com | last post by:
I have posted a couple times on here already and found the user community to be very helpful. I took on a project before I realized how difficult a time I'm having working with a database....
3
by: Alexander Widera | last post by:
Hi, i connect to a ms sql2000server via SqlConnection. if i make an SqlCommand "INSERT INTO mytable (mytext) VALUES (@mytext)" (or i make an update), and i pass the parameter @mytext a simple...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.