DataGrid Update Command

Discussion in 'ASP .Net Datagrid Control' started by Antony Futter, Jun 27, 2005.

  1. Hi,

    I am relatively new to .Net and have an question regarding updates from a
    Datagrid on an Webform.
    I have successfully got the data to display and then changed to the edit
    mode in the Grid, but when the update command is triggered, it seems to skip
    lines of code in the dataadaptor's auto-created code and it does not ever
    execute the update SProc on the SQL server.

    I have included the event code. Does anyone have any advice.

    Regards,
    Antony
    Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As
    System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
    DataGrid1.UpdateCommand
    SqlDataAdapter1.Update(Emaildata1)
    SqlDataAdapter1.Fill(Emaildata1)
    DataGrid1.DataBind()
    End Sub

    Me.SqlUpdateCommand1.CommandText = "[sp_web_emailaddress_update]"
    Me.SqlUpdateCommand1.CommandType = System.Data.CommandType.StoredProcedure
    Me.SqlUpdateCommand1.Connection = Me.SqlConnection1
    Me.SqlUpdateCommand1.Parameters.Add(New
    System.Data.SqlClient.SqlParameter("@RETURN_VALUE",
    System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
    False, CType(0, Byte), CType(0, Byte), "",
    System.Data.DataRowVersion.Current, Nothing))
    Me.SqlUpdateCommand1.Parameters.Add(New
    System.Data.SqlClient.SqlParameter("@emailaddress",
    System.Data.SqlDbType.VarChar, 200, "emailaddress"))
    Me.SqlUpdateCommand1.Parameters.Add(New
    System.Data.SqlClient.SqlParameter("@password",
    System.Data.SqlDbType.VarChar, 50, "password"))
    Me.SqlUpdateCommand1.Parameters.Add(New
    System.Data.SqlClient.SqlParameter("@enabled", System.Data.SqlDbType.Bit, 1,
    "enabled"))
    Me.SqlUpdateCommand1.Parameters.Add(New
    System.Data.SqlClient.SqlParameter("@passwordchange",
    System.Data.SqlDbType.Bit, 1, "passwordchange"))
    Me.SqlUpdateCommand1.Parameters.Add(New
    System.Data.SqlClient.SqlParameter("@Original_email_address_id",
    System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False,
    CType(0, Byte), CType(0, Byte), "email_address_id",
    System.Data.DataRowVersion.Original, Nothing))
    Me.SqlUpdateCommand1.Parameters.Add(New
    System.Data.SqlClient.SqlParameter("@Original_emailaddress",
    System.Data.SqlDbType.VarChar, 200, System.Data.ParameterDirection.Input,
    False, CType(0, Byte), CType(0, Byte), "emailaddress",
    System.Data.DataRowVersion.Original, Nothing))
    Me.SqlUpdateCommand1.Parameters.Add(New
    System.Data.SqlClient.SqlParameter("@Original_enabled",
    System.Data.SqlDbType.Bit, 1, System.Data.ParameterDirection.Input, False,
    CType(0, Byte), CType(0, Byte), "enabled",
    System.Data.DataRowVersion.Original, Nothing))
    Me.SqlUpdateCommand1.Parameters.Add(New
    System.Data.SqlClient.SqlParameter("@Original_password",
    System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input,
    False, CType(0, Byte), CType(0, Byte), "password",
    System.Data.DataRowVersion.Original, Nothing))
    Me.SqlUpdateCommand1.Parameters.Add(New
    System.Data.SqlClient.SqlParameter("@Original_passwordchange",
    System.Data.SqlDbType.Bit, 1, System.Data.ParameterDirection.Input, False,
    CType(0, Byte), CType(0, Byte), "passwordchange",
    System.Data.DataRowVersion.Original, Nothing))
    Me.SqlUpdateCommand1.Parameters.Add(New
    System.Data.SqlClient.SqlParameter("@email_address_id",
    System.Data.SqlDbType.Int, 4, "email_address_id"))
    Antony Futter, Jun 27, 2005
    #1
    1. Advertising

  2. By any chance, do you call Emaildata1.AccaptChanges()?

    Eliyahu

    "Antony Futter" <> wrote in message
    news:d9ofjh$i6k$...
    > Hi,
    >
    > I am relatively new to .Net and have an question regarding updates from a
    > Datagrid on an Webform.
    > I have successfully got the data to display and then changed to the edit
    > mode in the Grid, but when the update command is triggered, it seems to

    skip
    > lines of code in the dataadaptor's auto-created code and it does not ever
    > execute the update SProc on the SQL server.
    >
    > I have included the event code. Does anyone have any advice.
    >
    > Regards,
    > Antony
    > Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As
    > System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
    > DataGrid1.UpdateCommand
    > SqlDataAdapter1.Update(Emaildata1)
    > SqlDataAdapter1.Fill(Emaildata1)
    > DataGrid1.DataBind()
    > End Sub
    >
    > Me.SqlUpdateCommand1.CommandText = "[sp_web_emailaddress_update]"
    > Me.SqlUpdateCommand1.CommandType = System.Data.CommandType.StoredProcedure
    > Me.SqlUpdateCommand1.Connection = Me.SqlConnection1
    > Me.SqlUpdateCommand1.Parameters.Add(New
    > System.Data.SqlClient.SqlParameter("@RETURN_VALUE",
    > System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
    > False, CType(0, Byte), CType(0, Byte), "",
    > System.Data.DataRowVersion.Current, Nothing))
    > Me.SqlUpdateCommand1.Parameters.Add(New
    > System.Data.SqlClient.SqlParameter("@emailaddress",
    > System.Data.SqlDbType.VarChar, 200, "emailaddress"))
    > Me.SqlUpdateCommand1.Parameters.Add(New
    > System.Data.SqlClient.SqlParameter("@password",
    > System.Data.SqlDbType.VarChar, 50, "password"))
    > Me.SqlUpdateCommand1.Parameters.Add(New
    > System.Data.SqlClient.SqlParameter("@enabled", System.Data.SqlDbType.Bit,

    1,
    > "enabled"))
    > Me.SqlUpdateCommand1.Parameters.Add(New
    > System.Data.SqlClient.SqlParameter("@passwordchange",
    > System.Data.SqlDbType.Bit, 1, "passwordchange"))
    > Me.SqlUpdateCommand1.Parameters.Add(New
    > System.Data.SqlClient.SqlParameter("@Original_email_address_id",
    > System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False,
    > CType(0, Byte), CType(0, Byte), "email_address_id",
    > System.Data.DataRowVersion.Original, Nothing))
    > Me.SqlUpdateCommand1.Parameters.Add(New
    > System.Data.SqlClient.SqlParameter("@Original_emailaddress",
    > System.Data.SqlDbType.VarChar, 200, System.Data.ParameterDirection.Input,
    > False, CType(0, Byte), CType(0, Byte), "emailaddress",
    > System.Data.DataRowVersion.Original, Nothing))
    > Me.SqlUpdateCommand1.Parameters.Add(New
    > System.Data.SqlClient.SqlParameter("@Original_enabled",
    > System.Data.SqlDbType.Bit, 1, System.Data.ParameterDirection.Input, False,
    > CType(0, Byte), CType(0, Byte), "enabled",
    > System.Data.DataRowVersion.Original, Nothing))
    > Me.SqlUpdateCommand1.Parameters.Add(New
    > System.Data.SqlClient.SqlParameter("@Original_password",
    > System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input,
    > False, CType(0, Byte), CType(0, Byte), "password",
    > System.Data.DataRowVersion.Original, Nothing))
    > Me.SqlUpdateCommand1.Parameters.Add(New
    > System.Data.SqlClient.SqlParameter("@Original_passwordchange",
    > System.Data.SqlDbType.Bit, 1, System.Data.ParameterDirection.Input, False,
    > CType(0, Byte), CType(0, Byte), "passwordchange",
    > System.Data.DataRowVersion.Original, Nothing))
    > Me.SqlUpdateCommand1.Parameters.Add(New
    > System.Data.SqlClient.SqlParameter("@email_address_id",
    > System.Data.SqlDbType.Int, 4, "email_address_id"))
    >
    >
    >
    >
    >
    >
    Eliyahu Goldin, Jun 27, 2005
    #2
    1. Advertising

  3. Hi,

    No I do not. Do I need to do this before the update command.

    Thanks
    Antony


    "Eliyahu Goldin" <> wrote in message
    news:...
    > By any chance, do you call Emaildata1.AccaptChanges()?
    >
    > Eliyahu
    >
    > "Antony Futter" <> wrote in message
    > news:d9ofjh$i6k$...
    >> Hi,
    >>
    >> I am relatively new to .Net and have an question regarding updates from a
    >> Datagrid on an Webform.
    >> I have successfully got the data to display and then changed to the edit
    >> mode in the Grid, but when the update command is triggered, it seems to

    > skip
    >> lines of code in the dataadaptor's auto-created code and it does not ever
    >> execute the update SProc on the SQL server.
    >>
    >> I have included the event code. Does anyone have any advice.
    >>
    >> Regards,
    >> Antony
    >> Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As
    >> System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
    >> DataGrid1.UpdateCommand
    >> SqlDataAdapter1.Update(Emaildata1)
    >> SqlDataAdapter1.Fill(Emaildata1)
    >> DataGrid1.DataBind()
    >> End Sub
    >>
    >> Me.SqlUpdateCommand1.CommandText = "[sp_web_emailaddress_update]"
    >> Me.SqlUpdateCommand1.CommandType =
    >> System.Data.CommandType.StoredProcedure
    >> Me.SqlUpdateCommand1.Connection = Me.SqlConnection1
    >> Me.SqlUpdateCommand1.Parameters.Add(New
    >> System.Data.SqlClient.SqlParameter("@RETURN_VALUE",
    >> System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
    >> False, CType(0, Byte), CType(0, Byte), "",
    >> System.Data.DataRowVersion.Current, Nothing))
    >> Me.SqlUpdateCommand1.Parameters.Add(New
    >> System.Data.SqlClient.SqlParameter("@emailaddress",
    >> System.Data.SqlDbType.VarChar, 200, "emailaddress"))
    >> Me.SqlUpdateCommand1.Parameters.Add(New
    >> System.Data.SqlClient.SqlParameter("@password",
    >> System.Data.SqlDbType.VarChar, 50, "password"))
    >> Me.SqlUpdateCommand1.Parameters.Add(New
    >> System.Data.SqlClient.SqlParameter("@enabled", System.Data.SqlDbType.Bit,

    > 1,
    >> "enabled"))
    >> Me.SqlUpdateCommand1.Parameters.Add(New
    >> System.Data.SqlClient.SqlParameter("@passwordchange",
    >> System.Data.SqlDbType.Bit, 1, "passwordchange"))
    >> Me.SqlUpdateCommand1.Parameters.Add(New
    >> System.Data.SqlClient.SqlParameter("@Original_email_address_id",
    >> System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input,
    >> False,
    >> CType(0, Byte), CType(0, Byte), "email_address_id",
    >> System.Data.DataRowVersion.Original, Nothing))
    >> Me.SqlUpdateCommand1.Parameters.Add(New
    >> System.Data.SqlClient.SqlParameter("@Original_emailaddress",
    >> System.Data.SqlDbType.VarChar, 200, System.Data.ParameterDirection.Input,
    >> False, CType(0, Byte), CType(0, Byte), "emailaddress",
    >> System.Data.DataRowVersion.Original, Nothing))
    >> Me.SqlUpdateCommand1.Parameters.Add(New
    >> System.Data.SqlClient.SqlParameter("@Original_enabled",
    >> System.Data.SqlDbType.Bit, 1, System.Data.ParameterDirection.Input,
    >> False,
    >> CType(0, Byte), CType(0, Byte), "enabled",
    >> System.Data.DataRowVersion.Original, Nothing))
    >> Me.SqlUpdateCommand1.Parameters.Add(New
    >> System.Data.SqlClient.SqlParameter("@Original_password",
    >> System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input,
    >> False, CType(0, Byte), CType(0, Byte), "password",
    >> System.Data.DataRowVersion.Original, Nothing))
    >> Me.SqlUpdateCommand1.Parameters.Add(New
    >> System.Data.SqlClient.SqlParameter("@Original_passwordchange",
    >> System.Data.SqlDbType.Bit, 1, System.Data.ParameterDirection.Input,
    >> False,
    >> CType(0, Byte), CType(0, Byte), "passwordchange",
    >> System.Data.DataRowVersion.Original, Nothing))
    >> Me.SqlUpdateCommand1.Parameters.Add(New
    >> System.Data.SqlClient.SqlParameter("@email_address_id",
    >> System.Data.SqlDbType.Int, 4, "email_address_id"))
    >>
    >>
    >>
    >>
    >>
    >>

    >
    >
    Antony Futter, Jun 27, 2005
    #3
  4. No. Calling AcceptChanges() could've been the reason for your problem.

    Eliyahu

    "Antony Futter" <> wrote in message
    news:d9otfh$k8v$...
    > Hi,
    >
    > No I do not. Do I need to do this before the update command.
    >
    > Thanks
    > Antony
    >
    >
    > "Eliyahu Goldin" <> wrote in message
    > news:...
    > > By any chance, do you call Emaildata1.AccaptChanges()?
    > >
    > > Eliyahu
    > >
    > > "Antony Futter" <> wrote in message
    > > news:d9ofjh$i6k$...
    > >> Hi,
    > >>
    > >> I am relatively new to .Net and have an question regarding updates from

    a
    > >> Datagrid on an Webform.
    > >> I have successfully got the data to display and then changed to the

    edit
    > >> mode in the Grid, but when the update command is triggered, it seems to

    > > skip
    > >> lines of code in the dataadaptor's auto-created code and it does not

    ever
    > >> execute the update SProc on the SQL server.
    > >>
    > >> I have included the event code. Does anyone have any advice.
    > >>
    > >> Regards,
    > >> Antony
    > >> Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As
    > >> System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
    > >> DataGrid1.UpdateCommand
    > >> SqlDataAdapter1.Update(Emaildata1)
    > >> SqlDataAdapter1.Fill(Emaildata1)
    > >> DataGrid1.DataBind()
    > >> End Sub
    > >>
    > >> Me.SqlUpdateCommand1.CommandText = "[sp_web_emailaddress_update]"
    > >> Me.SqlUpdateCommand1.CommandType =
    > >> System.Data.CommandType.StoredProcedure
    > >> Me.SqlUpdateCommand1.Connection = Me.SqlConnection1
    > >> Me.SqlUpdateCommand1.Parameters.Add(New
    > >> System.Data.SqlClient.SqlParameter("@RETURN_VALUE",
    > >> System.Data.SqlDbType.Int, 4,

    System.Data.ParameterDirection.ReturnValue,
    > >> False, CType(0, Byte), CType(0, Byte), "",
    > >> System.Data.DataRowVersion.Current, Nothing))
    > >> Me.SqlUpdateCommand1.Parameters.Add(New
    > >> System.Data.SqlClient.SqlParameter("@emailaddress",
    > >> System.Data.SqlDbType.VarChar, 200, "emailaddress"))
    > >> Me.SqlUpdateCommand1.Parameters.Add(New
    > >> System.Data.SqlClient.SqlParameter("@password",
    > >> System.Data.SqlDbType.VarChar, 50, "password"))
    > >> Me.SqlUpdateCommand1.Parameters.Add(New
    > >> System.Data.SqlClient.SqlParameter("@enabled",

    System.Data.SqlDbType.Bit,
    > > 1,
    > >> "enabled"))
    > >> Me.SqlUpdateCommand1.Parameters.Add(New
    > >> System.Data.SqlClient.SqlParameter("@passwordchange",
    > >> System.Data.SqlDbType.Bit, 1, "passwordchange"))
    > >> Me.SqlUpdateCommand1.Parameters.Add(New
    > >> System.Data.SqlClient.SqlParameter("@Original_email_address_id",
    > >> System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input,
    > >> False,
    > >> CType(0, Byte), CType(0, Byte), "email_address_id",
    > >> System.Data.DataRowVersion.Original, Nothing))
    > >> Me.SqlUpdateCommand1.Parameters.Add(New
    > >> System.Data.SqlClient.SqlParameter("@Original_emailaddress",
    > >> System.Data.SqlDbType.VarChar, 200,

    System.Data.ParameterDirection.Input,
    > >> False, CType(0, Byte), CType(0, Byte), "emailaddress",
    > >> System.Data.DataRowVersion.Original, Nothing))
    > >> Me.SqlUpdateCommand1.Parameters.Add(New
    > >> System.Data.SqlClient.SqlParameter("@Original_enabled",
    > >> System.Data.SqlDbType.Bit, 1, System.Data.ParameterDirection.Input,
    > >> False,
    > >> CType(0, Byte), CType(0, Byte), "enabled",
    > >> System.Data.DataRowVersion.Original, Nothing))
    > >> Me.SqlUpdateCommand1.Parameters.Add(New
    > >> System.Data.SqlClient.SqlParameter("@Original_password",
    > >> System.Data.SqlDbType.VarChar, 50,

    System.Data.ParameterDirection.Input,
    > >> False, CType(0, Byte), CType(0, Byte), "password",
    > >> System.Data.DataRowVersion.Original, Nothing))
    > >> Me.SqlUpdateCommand1.Parameters.Add(New
    > >> System.Data.SqlClient.SqlParameter("@Original_passwordchange",
    > >> System.Data.SqlDbType.Bit, 1, System.Data.ParameterDirection.Input,
    > >> False,
    > >> CType(0, Byte), CType(0, Byte), "passwordchange",
    > >> System.Data.DataRowVersion.Original, Nothing))
    > >> Me.SqlUpdateCommand1.Parameters.Add(New
    > >> System.Data.SqlClient.SqlParameter("@email_address_id",
    > >> System.Data.SqlDbType.Int, 4, "email_address_id"))
    > >>
    > >>
    > >>
    > >>
    > >>
    > >>

    > >
    > >

    >
    >
    Eliyahu Goldin, Jun 27, 2005
    #4
    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. =?Utf-8?B?YWJkb2x5?=

    datagrid update command

    =?Utf-8?B?YWJkb2x5?=, Jun 1, 2004, in forum: ASP .Net
    Replies:
    10
    Views:
    6,051
    sobin
    Mar 19, 2005
  2. John Blair

    Datagrid update command - and validators

    John Blair, Jan 24, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    3,235
    vgebrev
    Jan 30, 2008
  3. =?Utf-8?B?TWljaGFlbA==?=

    How to update datagrid after update

    =?Utf-8?B?TWljaGFlbA==?=, Mar 17, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    500
    Alex D.
    Mar 17, 2006
  4. Andreas Klemt
    Replies:
    0
    Views:
    295
    Andreas Klemt
    Oct 8, 2003
  5. prakash
    Replies:
    2
    Views:
    586
    prakash
    Apr 11, 2005
Loading...

Share This Page