hambo12
05-11-2010, 05:08 AM
Ok so im a bit lost. I have the following ASP page that updates a Database with the data input into the form. This is created by using a Dreamweaver template:
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If
' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
If (CStr(Request("MM_insert")) = "form") Then
If (Not MM_abortEdit) Then
' execute the insert
Dim MM_editCmd
Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_CRM_STRING
MM_editCmd.CommandText = "INSERT INTO dbo.Address ([State], Town, Street, HouseNumber, UnitNumber) VALUES (?, ?, ?, ?, ?)"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 201, 1, 255, Request.Form("State")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 201, 1, 255, Request.Form("Town")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 201, 1, 255, Request.Form("Street")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 201, 1, 255, Request.Form("HouseNumber")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 201, 1, 255, Request.Form("UnitNumber")) ' adLongVarChar
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
' append the query string to the redirect URL
Dim MM_editRedirectUrl
MM_editRedirectUrl = "Address_Results.asp"
<form name="form" method="POST" action="<%=MM_editAction%>">
State: <input type="text" name="State" maxlength="20" /><br><br>
Town: <input type="text" name="Town" maxlength="20"><br><br>
Street: <input type="text" name="Street" maxlength="20" /><br><br>
House Number: <input type="text" name="HouseNumber" maxlength="20" />
Unit Number: <input type="text" name="UnitNumber" maxlength="20" />
<input type="submit" name="Submit" value="Apply">
<input type="hidden" name="MM_insert" value="form" />
</form>
So this redirects the page to a new ASP page. however I cant work out how to display the values that have been added to the database.
I have tried request.form("State") etc, but cant get it to display.
What is the easiest way to do this?
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If
' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
If (CStr(Request("MM_insert")) = "form") Then
If (Not MM_abortEdit) Then
' execute the insert
Dim MM_editCmd
Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_CRM_STRING
MM_editCmd.CommandText = "INSERT INTO dbo.Address ([State], Town, Street, HouseNumber, UnitNumber) VALUES (?, ?, ?, ?, ?)"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 201, 1, 255, Request.Form("State")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 201, 1, 255, Request.Form("Town")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 201, 1, 255, Request.Form("Street")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 201, 1, 255, Request.Form("HouseNumber")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 201, 1, 255, Request.Form("UnitNumber")) ' adLongVarChar
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
' append the query string to the redirect URL
Dim MM_editRedirectUrl
MM_editRedirectUrl = "Address_Results.asp"
<form name="form" method="POST" action="<%=MM_editAction%>">
State: <input type="text" name="State" maxlength="20" /><br><br>
Town: <input type="text" name="Town" maxlength="20"><br><br>
Street: <input type="text" name="Street" maxlength="20" /><br><br>
House Number: <input type="text" name="HouseNumber" maxlength="20" />
Unit Number: <input type="text" name="UnitNumber" maxlength="20" />
<input type="submit" name="Submit" value="Apply">
<input type="hidden" name="MM_insert" value="form" />
</form>
So this redirects the page to a new ASP page. however I cant work out how to display the values that have been added to the database.
I have tried request.form("State") etc, but cant get it to display.
What is the easiest way to do this?