Fully Editable Datagrid - Update Command does not make updates

Discussion in 'ASP .Net' started by juustagirl@yahoo.com, May 12, 2006.

  1. Guest

    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, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Walburn

    Fully editable datagrid

    Peter Walburn, Sep 3, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    9
    Views:
    136
  2. Viren

    Fully multiple, editable dynamic datagrid.

    Viren, Oct 20, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    132
    Alvin Bruney
    Oct 20, 2003
  3. Pawan Gupta

    Fully Editable Datagrid

    Pawan Gupta, May 19, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    138
    SoftLion
    May 19, 2004
  4. Karthik

    fully editable Datagrid..not bound to database..

    Karthik, Jan 11, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    147
    Karthik
    Jan 11, 2005
  5. fizzy

    fully editable datagrid causing crash

    fizzy, Jun 21, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    3
    Views:
    100
    Elton Wang
    Jun 21, 2005
Loading...

Share This Page