automatically update or insert record
I was wondering if it is possible to automatically update or insert a record after executing a function by using the dreamweaver mx update record behavior, but without using any server side control (without the user clicking a submit button or any other command). This web page will only request two cookies and insert the value on a table.
I have try different ways but it seems that the values of my hiddenforms that I use to insert the records are deleted before executing the Insertar.Expression.Doinit()
This is what I am doing:
''''''''''This is my insert record behavior code
<MM:Insert
runat="server"
id="insertar"
CommandText='<%# "INSERT INTO dbo.Waist (WaistID, Waist) VALUES (@WaistID, @Waist)" %>'
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_STRING_TMDatabase") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_DATABASETYPE_TMDatabase") %>'
Expression="false"
CreateDataSet="false"
SuccessURL='<%# "index.htm" %>'
Debug="true"
><Parameters>
<Parameter Name="@WaistID" Value='<%# IIf((Request.Form("hf_PID") <> Nothing), Request.Form("hf_PID"), "") %>' Type="BigInt" />
<Parameter Name="@Waist" Value='<%# IIf((Request.Form("hf_PID2") <> Nothing), Request.Form("hf_PID2"), "") %>' Type="Int" />
</Parameters>
</MM:Insert>
'''''This is where I initialize the cookies
<script runat="server">
Public PatientID as HttpCookie
Public waist2 as HttpCookie
Public wasitstring as string
Sub Page_Init(Src As Object, E As EventArgs)
PatientID = request.Cookies("pPatientID")
waist2 = request.Cookies("pWaist")
End Sub
</script>
'''''This is where I assigne the cookies to a hidden form and then call the INSERT behavior to insert the values to the database
<script runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
hf_PID.Value= PatientID.value
hf_PID2.Value = waist2.value
Label1.Text = Cstr(hf_PID.Value) + Cstr(hf_PID2.Value)
insertar.Expression = "true"
insertar.DoInit()
insertar.Expression = "false"
End Sub
</script>
--------------------------------------------------------------------------------
I have also tried to put all the code under the Sub Page_Load(Src As Object, E As EventArgs) or Sub Page_Prerednder(Src As Object, E As EventArgs) functions but nothing happens.
If I use the UPDATE RECORD BEhavior instead of the INSERT RECORD, it will take me to the success page but without updating the hidden forms values on the database.
Do you have any suggestions? DoI need to include something else besides insertar.Expression = "true" ?
Thank you,
|