2014年7月13日 星期日

[RESOLVED] Run SQL after the INSERT is clicked on DetailsView


I want to run a little UPDATE query after the user has clicked on the INSERT button on the detailsview.


So I guess within the VB page, on ItemInserted I need some sort line to run a UPDATE query…


How do I do this??


Below is the current vb script


Private Sub DetailsView1_ItemInserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewInsertedEventArgs) Handles DetailsView1.ItemInserted
Page.ClientScript.RegisterStartupScript(Me.GetType(), "MyScript", "alert('your data has been successfully stored!');", True)

End Sub


I want to add another line…


UPDATE myTable
Set Rating IS NULL
WHERE Rating = ‘0’



Add another SqlDataSource to the page, set update command. Then call update() like : SqlDataSourceRating.Update()

I've created a new SQLDATASOURCE at the bottom of the page, which contains an
UPDATECOMMAND.


        ConnectionString="<%$ ConnectionStrings:NCRSDBConnectionString %>"
UpdateCommand="UPDATE dbo.AR_20120209_ChaplaincyPatientList Set Rating = NULL WHERE Rating = '0'">

How do I reference this to the INSERT button on the DETAILSVIEW



    Protected Sub DetailsView1_ItemInserted(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DetailsViewInsertedEventArgs) Handles DetailsView1.ItemInserted
UPDATE_RATING.Update()
End Sub


沒有留言:

張貼留言