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

Datagrid doesn't update

I am using vb.net and have a bounded datagrid by using SQLDataAdaptor
and SQLDataSet, it does show the data when it is first loaded. But
when I change the data on the datagrid, it doesn't update the
database, even I use AcceptChanges...

What am I missing? What I am expecting is it should update the
database automatically without doing it manually with the code.

Please help!!!!

Thanks in advance.
Wanda
Nov 20 '05 #1
3 1660
Are you sure your dataset .HasChanges before calling update? IF not, calling
update all year won't do anything. And DO NOT CALL acceptchanges before the
update. This will essentially return the rowstates of everything back to
Unchanged and it will physically delete rows marked as Deleted. If you call
AcceptChanges before Update, your DB will never be updated.

ALso, are you getting an exception on update? Make sure it's not wrapped in
try catch with no action being taken...that can mask errors.

If HasChanges is true, your update command is valid you should be able to
update. If no exceptions are thrown, you have a weird problem indeed, but I
don't think it's that.

Let me know.
"Wanda" <wa*****@rogers.com> wrote in message
news:11**************************@posting.google.c om...
I am using vb.net and have a bounded datagrid by using SQLDataAdaptor
and SQLDataSet, it does show the data when it is first loaded. But
when I change the data on the datagrid, it doesn't update the
database, even I use AcceptChanges...

What am I missing? What I am expecting is it should update the
database automatically without doing it manually with the code.

Please help!!!!

Thanks in advance.
Wanda

Nov 20 '05 #2
I've an Update button on my screen...when the button is clicked the
following code will be executed...So, I have no idea what I am missing.
Is there any setting I have to apply to the dataset or the datagrid in
order to update the changes?

If custDS.HasChanges Then
custDS.AcceptChanges()
End If

Please suggest. Thanks in advance.

Wanda

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #3
AcceptChanges does not send an update to the db Don't ever call this before
DataAdapter.Update(dataset) or it Will NEVER be updated. This changes the
rowstates of the added/delted/modified rows back to unchanged(well, it
actually deletes the deleted rows).

Call DataAdapter.Update(dataSet, datatable) instead
"Wanda Li" <wa*****@rogers.com> wrote in message
news:Oa*************@tk2msftngp13.phx.gbl...
I've an Update button on my screen...when the button is clicked the
following code will be executed...So, I have no idea what I am missing.
Is there any setting I have to apply to the dataset or the datagrid in
order to update the changes?

If custDS.HasChanges Then
custDS.AcceptChanges()
End If

Please suggest. Thanks in advance.

Wanda

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #4

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

Similar topics

9
by: Pam Ammond | last post by:
After clicking btnDeleteSize_Click in frmSize, I move to frmSizeDelete, allow deleting a Size using a datagrid, and then return to frmSize and want to update the datagrid in frmSize to reflect the...
9
by: tshad | last post by:
Is there a way to use your own image in place of the automatic one that ASP uses when doing editing in your DataGrid pages? We already have a style of button we are using and would like to be...
4
by: tshad | last post by:
I am having trouble with links in my DataGrid. I have Links all over my page set to smaller and they are consistant all over the page in both Mozilla and IE, except for the DataGrid. Here is a...
13
by: Lyners | last post by:
I have a web page writen in ASP.NET that contains some javascript so that when a user presses a button, or edits a certain field in a datagrid, another cell in the datagrid is filled with a value....
5
by: Jay Villa | last post by:
Is it possible to update only few columns in datagrid during OnUpdateCommand event ? If so, could you help me .... -thanks Jay
3
by: Larry Woods | last post by:
I have a datagrid that is carrying all fields of a record...except one. Now I want to update the underlying database via a dataadapter. The update is working but the field that is "left out" is...
4
by: drakuu | last post by:
Hello there, I have DataGrid with some records and I would like to edit it right in the datagrid using the built in commands. I can't figure out a way to pass to the SQL query the record ID...
0
by: rn5a | last post by:
Suppose I have the following DataGrid: <asp:DataGrid ID="dgUsers" OnUpdateCommand="UpdateDG" runat="server"> <Columns> <TemplateColumn HeaderText="NAME"> <ItemTemplate> <asp:Label...
13
by: shookim | last post by:
I don't care how one suggests I do it, but I've been searching for days on how to implement this concept. I'm trying to use some kind of grid control (doesn't have to be a grid control, whatever...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.