Copy link to clipboard
Copied
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 server behaviour:
<%
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 which doesnt display anything. However I cant work out how to display the values that have been added to the database.
What is the easiest way to do this? What syntax can I use to display the parameters in a new ASP page?
Copy link to clipboard
Copied
To display what was just inserted, your 'results' page will either need to query the database and select the results, or you can save the form input values into session variables and display those. I would suggest option 1. To do this, need a way to identify the row that was inserted. What dbms are you using? What is the primary key of your table?
Copy link to clipboard
Copied
Hi, I am using SQL Server Express 2008. My table has a Primary key named address_id.
So how do I pass the Primary Key of the row I just created?
Copy link to clipboard
Copied
Are you creating the address_id or is it auto generated by SQL Server?
Copy link to clipboard
Copied
Address_ID is auto generated by SQL...
Copy link to clipboard
Copied
Use select @@identity to get the last identity value produced for a connection.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more