Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Datagrid Control (http://www.velocityreviews.com/forums/f60-asp-net-datagrid-control.html)
-   -   DataGrid Update Command (http://www.velocityreviews.com/forums/t762110-datagrid-update-command.html)

Antony Futter 06-27-2005 09:02 AM

DataGrid Update Command
 
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("@passwordchang e",
System.Data.SqlDbType.Bit, 1, "passwordchange"))
Me.SqlUpdateCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_emai l_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_emai laddress",
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_enab led",
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_pass word",
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_pass wordchange",
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 06-27-2005 11:05 AM

Re: DataGrid Update Command
 
By any chance, do you call Emaildata1.AccaptChanges()?

Eliyahu

"Antony Futter" <ajfnews@asf.co.za> wrote in message
news:d9ofjh$i6k$1@ctb-nnrp2.saix.net...
> 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("@passwordchang e",
> System.Data.SqlDbType.Bit, 1, "passwordchange"))
> Me.SqlUpdateCommand1.Parameters.Add(New
> System.Data.SqlClient.SqlParameter("@Original_emai l_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_emai laddress",
> 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_enab led",
> 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_pass word",
> 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_pass wordchange",
> 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 06-27-2005 12:59 PM

Re: DataGrid Update Command
 
Hi,

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

Thanks
Antony


"Eliyahu Goldin" <removemeegoldin@monarchmed.com> wrote in message
news:OyaXf7veFHA.2740@TK2MSFTNGP10.phx.gbl...
> By any chance, do you call Emaildata1.AccaptChanges()?
>
> Eliyahu
>
> "Antony Futter" <ajfnews@asf.co.za> wrote in message
> news:d9ofjh$i6k$1@ctb-nnrp2.saix.net...
>> 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("@passwordchang e",
>> System.Data.SqlDbType.Bit, 1, "passwordchange"))
>> Me.SqlUpdateCommand1.Parameters.Add(New
>> System.Data.SqlClient.SqlParameter("@Original_emai l_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_emai laddress",
>> 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_enab led",
>> 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_pass word",
>> 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_pass wordchange",
>> 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 06-27-2005 02:44 PM

Re: DataGrid Update Command
 
No. Calling AcceptChanges() could've been the reason for your problem.

Eliyahu

"Antony Futter" <ajfnews@asf.co.za> wrote in message
news:d9otfh$k8v$1@ctb-nnrp2.saix.net...
> Hi,
>
> No I do not. Do I need to do this before the update command.
>
> Thanks
> Antony
>
>
> "Eliyahu Goldin" <removemeegoldin@monarchmed.com> wrote in message
> news:OyaXf7veFHA.2740@TK2MSFTNGP10.phx.gbl...
> > By any chance, do you call Emaildata1.AccaptChanges()?
> >
> > Eliyahu
> >
> > "Antony Futter" <ajfnews@asf.co.za> wrote in message
> > news:d9ofjh$i6k$1@ctb-nnrp2.saix.net...
> >> 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("@passwordchang e",
> >> System.Data.SqlDbType.Bit, 1, "passwordchange"))
> >> Me.SqlUpdateCommand1.Parameters.Add(New
> >> System.Data.SqlClient.SqlParameter("@Original_emai l_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_emai laddress",
> >> 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_enab led",
> >> 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_pass word",
> >> 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_pass wordchange",
> >> 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"))
> >>
> >>
> >>
> >>
> >>
> >>

> >
> >

>
>





All times are GMT. The time now is 10:36 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.