Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Fully Editable Datagrid - Update Command does not make updates

Reply
Thread Tools

Fully Editable Datagrid - Update Command does not make updates

 
 
juustagirl@yahoo.com
Guest
Posts: n/a
 
      05-12-2006
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
fully editable datagrid causing crash fizzy ASP .Net Datagrid Control 3 06-21-2005 01:01 PM
fully editable Datagrid..not bound to database.. Karthik ASP .Net Datagrid Control 0 01-11-2005 06:23 PM
Fully Editable Datagrid Pawan Gupta ASP .Net Datagrid Control 2 05-19-2004 04:06 PM
Fully editable datagrid Peter Walburn ASP .Net Datagrid Control 9 12-12-2003 08:41 AM
Fully multiple, editable dynamic datagrid. Viren ASP .Net Datagrid Control 1 10-20-2003 06:53 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57