Updating dataset using datagrid

Table Adapter uses the key column in the Where clause of its Update and Delete statements so if the value of key column changes, things get messy. Then I have a separate "Update" button that the users pushes to start the update process.

That way you could edit many rows and just have one update going on to handle all of the actions.

Where the data in column "ID" in my SQL matches the data in column "ID" of my datagrid, I want the data in column "Customer" of my datagrid updated in column "Customer" of my SQL table and so far I have the following code: on mouse Up //CONNECT TO DATABASE -- use a global variable to hold the connection ID so other scripts can use it global g Connection ID -- set up the connection parameters - edit these to suit your database put "XXXXX" into t Database Address put "XXXXXX" into t Database Name put "XXXXX" into t Database User put "XXXXX" into t Database Password -- connect to the database put rev Open Database("My SQL", t Database Address, t Database Name, t Database User, t Database Password) into t Result -- check if it worked and display an error message if it didn't -- & set the connection ID global if t Result is a number then put t Result into g Connection ID //answer info "Proposal Generated." & cr & "Connection ID = " & g Connection ID else put empty into g Connection ID end if //ADD TO DATABASE -- check the global connection ID to make sure we have a database connection global g Connection ID if g Connection ID is not a number then answer error "Please connect to the database first." exit to top end if put the dg Text of group "Upgrade" into t Upgrade set the itemdelimiter to tab repeat with y = 1 to the number of lines of t Upgrade put "UPDATE Mobile Info Login SET Account Manager=" & "'" & (item 2 of line y of t Upgrade) & "'" & "WHERE ID=" & "'" & (item 1 of line y of t Upgrade) & "'" into t SQL end repeat -- send the SQL to the database, filling in the placeholders with data from variables rev Execute SQL g Connection ID, t SQL -- check the result and display the data or an error message if the result is a number then answer info "Handset Cost Updated." else answer error "There was a problem updating the record to the database:" & cr & the result end if //DISCONNECT FROM DATABASE global g Connection ID -- if we have a connection, close it and clear the global connection ID if g Connection ID is a number then rev Close Database g Connection ID put empty into g Connection ID end if end mouse Up Problem with the code is that only the last line of the datagrid updates my my SQL table.

Dim e DS As New Data Set Dim e DA As New Ole Db Data Adapter e DS = BNew Dataset e Da = New Ole Db Adapter.

where you pull from the database, edit the locally cached copy, and then post the changes back.

Hi All I am trying to update the data that is stored in my SQL with the data that is in my datagrid.

It confuses me to see the 'write to XML' example create three files.

I have a datagrid that I use to display data from a SQL 2000 table.

Search for updating dataset using datagrid:

updating dataset using datagrid-41

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “updating dataset using datagrid”

  1. Navigation to the different chat rooms may be accomplished by clicking the room list option at the upper right of the chat area. Click a listed chat room to prompt the login to the desired room.