473,320 Members | 1,865 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,320 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 1133

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...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.