473,756 Members | 3,499 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1689
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.goo gle.com...
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.HasChang es Then
custDS.AcceptCh anges()
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.Upd ate(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.Upd ate(dataSet, datatable) instead
"Wanda Li" <wa*****@rogers .com> wrote in message
news:Oa******** *****@tk2msftng p13.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.HasChang es Then
custDS.AcceptCh anges()
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
1646
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 deletion. I can't figure out how to get the datagrid in frmSize updated, although the datagrid in frmSizeDelete shows the deletion properly. In frmSizeDelete the size is properly deleted when the user clicks the row in the datagrid and presses...
9
4608
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 consistant. Thanks, Tom.
4
3496
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 snippet from my .css file: *************************** body { margin:0; padding:0;
13
2670
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. My probelm.... when I have the user press the update button (which does a post back that loops through the datagrid and updates a database) the field/cell that is filled by the javascript appears to be blank in my update code, even though I can...
5
2436
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
1878
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 not there, of course. How do I get that field back into the datatable for the database update? TIA, Larry Woods
4
9698
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 which I'm editing. SELECT: SelectCommand="SELECT ProviderID, AddressID, Address, Address2, City, State, County, Zip FROM ProviderAddress WHERE (ProviderID = @ProviderID)"
0
2670
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 ID="lblFName" runat="server"><%# Container.DataItem("FName") %></asp:Label> </ItemTemplate> <EditItemTemplate>
13
2456
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 works best) to display a dropdown menu of fields populated from table tblInvoiceData. This control also includes a textbox which the user can input a value. These two columns are side by side and not in a vertical layout. The user then clicks on...
0
9456
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9273
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9872
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9841
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7244
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5303
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.