473,396 Members | 1,998 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,396 software developers and data experts.

Why isn't my data adapter updating?

I've got a simple windows form with some bound textboxes
and Save button. Each texbox is bound to column in a table
in an Access database. The form fills fine - all the
fields show the correct data for the record I load. So
then I change the contents of one of the textboxes and
click on the Save button. The button's event handler then
calls the data adapter's Update method and I check the
return value. Nada-zilch-nothing. I even put a breakpoint
there, dug into the DataSet in the debugger and found the
DataRow in question. Sure enough, there is my changed
data but RowState is showing Unchanged. The documentation
("Introduction to DataSet Updates") says: "In Windows
Forms, the data-binding architecture takes care of sending
changes from data-bound controls to the dataset, and you
do not have to explicitly update the dataset with your own
code." Sounds pretty clear to me but obviously it's not
working the way I think it should. What am I missing??


Nov 15 '05 #1
1 5263
MP
look this tread from the databinding group:

I hope this help...

MP

"Stuart Powers" <de*******@yahoo.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
I have solved the problem.

the problem was, for a datarow that you're editing, before you edit it you
have to call BeginEdit(), then when all the changes are done, before you
Update() (stick the datatable back in the database) you have to call
EndEdit(). After you update, call AcceptChanges(), which changes tells the datatable it is synch'd with the database, sorta.

The reason a datagrid was working and not the textbox, i suspect, is because the datagrid internally takes care of the BeginEdit()/EndEdit() things.

Hope this helps, if not, write back

-Stu

----- Original Message -----
From: "MP" <m.******@codetel.net.do>
Newsgroups: microsoft.public.dotnet.framework.windowsforms.dat abinding
Sent: Monday, August 11, 2003 7:13 PM
Subject: Re: Binding Problem: TextBox vs. DataSet (maybe simple solution?)

Hello

I found this tread a few day ago, is from a Spanish group but I think you
can understand the idea, if you need more translation, tell me.

I have the same problem and the same frustration, but now I'm on other
problem and going to try this solution later.

If you get the solution please let me know, I will do the same when I look for it

I hope this help.

MP

---------------

from: microsoft.public.es.csharp

Buen esto ocurre por que no se ha terminado la operación de edición actual,
es por eso que desplazar el currency manager tambien funciona, pero, ¿si
existe solo un registro acia donde desplazar =( ?.

'Si la operación de edicion se realiza desde un Datagrid mDataGrid

Me.mGrid.EndEdit(Me.mTableStyle.GridColumnStyles(M e.mGrid.CurrentCell.Column
Number), _

Me.mGrid.CurrentCell.RowNumber, False)

CType(Me.BindingContext(Me.mGrid.DataSource),
CurrencyManager).EndCurrentEdit()

'Si la operación de edicion se realiza a travez de un DataView

CType(Me.BindingContext(Me.mDataView), CurrencyManager).EndCurrentEdit()

'Si la operación de edicion se realiza a travez de un DataTable en un
DataSet

CType(Me.BindingContext(Me.mDataSet.mDataTable),
CurrencyManager).EndCurrentEdit()
"Stuart Powers" <de*******@yahoo.com> wrote in message
news:OP**************@TK2MSFTNGP10.phx.gbl...
Hello,

This is a /very/ odd problem and any insight would be greatly

appreciated.
1) I have used SqlDataAdapter to fill a DataTable in a DataSet.
2) I binded textbox's "Text" property to columns in the DataTable.
3) I edit the textboxes Text value.
in doing so, the DataTable's values have changed
I know this because i have done:
MessageBox.Show(dataTable.Rows[0]["colname"].ToString());
4) I attempt to update the database: myDataAdapter.Update(myDataSet,
"tablename");
this does not work.

now the weird part:

if you replace steps 2 and 3 with:
2) Create a datagrid whose DataSource = myDataSet.Tables["tablename"];
3) make changes in the datagrid

then step will 4 work correctly. (somehow the datagrid must change the dataset differently than the textboxes do, it appears)
however, this makes no sense, because doing:
MessageBox.Show(dataTable.Rows[0]["colname"].ToString());
prints the same thing with both methods

what is /really/ weird:

Suppose I have both the textboxes and the datagrid, both bound to the
DataTable. When I edit a textbox, then try and update the database, it sitll doesn't work (as expected, because it didn't work before). However, If I edit a textbox, then merely click on the datagrid (give it focus) the value in the datagrid then changes (as if its being refreshed to show the change I made to the textbox). now, after clicking the datagrid, when I press try and update the database: myDataAdapter.Update(myDataSet,
"tablename"); it WORKS.

I have have absolutely no idea why merely clicking on the datagrid
makes a difference. They are both bound to the same DataSet/DataTable.

Any help would be greatly appreciated as I am quite stumped.
Thanks,
Stuart


Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Terry Knight | last post by:
hey, i've created a data adpater called 'dabvscores' i've created a dataset called 'dsvbscores' now i've greated a private sub to populate the data adpater and then i fill the dataset and...
2
by: headware | last post by:
I'm relatively new to ASP.NET and ADO.NET, but I have a basic design question regarding the use of web services and APS.NET applications. Right now we have an application that uses web services to...
5
by: Rick | last post by:
The data adapter wizard allows you to add more than one table, but that doesn't seem to work right when setting up a dataset. Some of the documentation I have read states that only one table...
4
by: William | last post by:
After much frustration I was able to update my data store via code only. Using the data adapter was the only way I was able to set up all the objects written in my code. Basically, I cheated by...
1
by: Spock | last post by:
Hi. I have a form with a listbox and a few label fields all bound to a dataset. When i navigate the listbox the labels change accordingly. so far everything works good. I made a button to...
1
by: Adam | last post by:
This is kind of a tough question, but, I'm working on a program now and using sql data adapters with sql server to generate data tables. I'm updating the tables and then using the...
6
by: pooba53 | last post by:
I have a VB .NET application that is communicating properly with an Access DB. I have a slew of textbox controls bound to a dataset and when the application launches, the fields are correctly...
3
by: Fred Chateau | last post by:
Any obvious reason here why data is not being loaded into the database? SqlDataAdapter dataAdapter = new SqlDataAdapter(sqlCommand); SqlCommandBuilder commandBuilder = new...
9
by: SAL | last post by:
Hello, I have a Dataset that I have table adapters in I designed using the designer (DataLayer). I have a business logic layer that immulates the DataLayer which may/may not have additional logic...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.