473,287 Members | 2,263 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,287 software developers and data experts.

Fully Editable Datagrid - Update Command does not make updates

There is only one editable field on my datagrid ... a combo box.

The data displays correctly. I have a button to make all the changes
.... but they are never written back to my Access database.

I have tried Response.write lines to see that I get the correct value
for Id and Status for my command. I do not get any errors, but the
changes are not made to the database!?!?


Sub btnSaveAll_Click(sender As Object, e As EventArgs)
'save all updates made to datagrid
'Create connection and command objects
Dim myConnection as New oledbConnection(ConnectionString)
Dim updateSQL as String = "UPDATE Lead SET Status = @Status WHERE
LeadID = @ID"
myConnection.open()
Dim myCommand as New oledbCommand(updateSQL, myConnection)

Dim dgi as DataGridItem
For Each dgi in DataGrid1.Items
'Read in the Primary Key Field
Dim id as Integer =
Convert.ToInt32(DataGrid1.DataKeys(dgi.ItemIndex))
Dim status as String = CType(dgi.FindControl("cmbStatuses"),
DropDownList).Text
'Issue an UPDATE statement...
updateSQL = "UPDATE Lead SET Status = @Status WHERE LeadID =
@ID"

myCommand.Parameters.Clear()
myCommand.Parameters.Add("@id", id)
myCommand.Parameters.Add("@Status", status)
myCommand.ExecuteNonQuery()

Next

End Sub

May 12 '06 #1
0 1132

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

Similar topics

3
by: EMW | last post by:
How can I put everything that is in a datagrid into a SQL server database (which should be readable by an PocketPC program)? There is probably a simple solution for it, but as always it is...
0
by: NETDeveloper | last post by:
Hi, I almost have my nested datagrid working properly. I created a datagrid on a user control and dropped that onto another datagrid. At first, I noticed when I was stepping through the code,...
11
by: Junkguy | last post by:
I need some help programmatically causing a row in a DataGrid to "flush" its contents to its bound data (in Visual Studio 6 using Windows Forms with C#). My issue is I want to send an update to...
3
by: Kevin Pedersen | last post by:
Hello, I am using an editable datagrid. After I save the changes the datagrid shows the old values. I've read the posts about the Page_Load and not binding the datagrid each time. The SQL that...
4
by: Stephan Bour | last post by:
Hi, I have a datagrid databound to a SQL query. I'd like to allow editing of some columns but not all. Is there a way to turn off the conversion of the datagrid cells to textboxes for some columns...
2
by: Stephan Bour | last post by:
Hi, Ičve tried to implement a solution to populate a dropdownlist inside an editable datagrid. The code is simple enough and an example can be found here:...
1
by: AA | last post by:
We want to edit, update data of DataGrid in Asp.Net with VB.Net.and are writing the following code for EditCommand and UpdateCommand Event is : DataGrid1_EditCommand
2
by: Frank | last post by:
Hello, I am developing with VS.Net 2003 on the asp 1.1 platform. I am a few days new to using a datagrid. I found a nice tutorial and had no problems using an editable datagrid with textboxes...
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
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...
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)...

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.