Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Dreamweaver Insert - how to Pass Parameters to new Page?

New Here ,
May 12, 2010 May 12, 2010

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?

TOPICS
Server side applications
2.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 12, 2010 May 12, 2010

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 12, 2010 May 12, 2010

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 13, 2010 May 13, 2010

Are you creating the address_id or is it auto generated by SQL Server?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 16, 2010 May 16, 2010

Address_ID is auto generated by SQL...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 16, 2010 May 16, 2010
LATEST

Use select @@identity to get the last identity value produced for a connection.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines