473,385 Members | 1,867 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,385 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 2300
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...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.