Removing 1 of 2 url parameters after inserting a record

Posted on 2003-03-20
Medium Priority
Last Modified: 2010-04-25
Situation is, I have a detail page (vendor_detail.asp) for a particular vendor, displaying all of his equipment.  This page has an existing url parameter for the vendor's specific id (vendor_id) so that only his equipment is displayed.  You can click on each piece of equipment to go and edit the details of that equipment (equip_edit.asp).  Currently, when you click on the equipment piece, it will create a new url parameter(equip_id) so that the edit page only displays that piece of equipement for editing.  Additionally, I am passing the existing url parameter of vendor_id so that I can pass it back after submitting the edit equipment (and return to the same vendor_detail.asp page).

My problem is that after submitting the updated equipment record, it is passing back both url parameters (vendor_id and equip_id).  This is a problem if I want to edit the equipment detail again as it will now have 3 url parameters (vendor_id and 2 equip_id's), and errors out the page, message included for giggles.

ADODB.Recordset.1 error '80004005'

SQLState: 42000
Native Error Code: 1064
[TCX][MyODBC]You have an error in your SQL syntax near ' 2' at line 1

I am using the built in functionality of Dreamweaver for "Go to Detail Page".

I guess my question has a couple parts:

a) I don't remember specifying in the first place that the equip_edit.asp should pass url parameters back after submitting the update record.  Is this a default when using the "update record" behavior?

b) How can you selectively pass back url parameters?  I don't see this as built in to dreamweaver.  The only url parameter I want to pass back is the vendor_id one.

I have relatively meager hand coding skills, though I can certainly follow directions like a champ.

Any help here would be appreciated.

Question by:keeper3
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Expert Comment

ID: 8193245
Can u post the code here for us to have a look. It might have to be handled at the background using some ASP skills.


Accepted Solution

welcht earned 750 total points
ID: 8310011
Your code would definitely help clarify what all's going on and what you don't need.
But to answer part a) yes it is a dreamweaver default that the parameter is passed when updating a record.  You can take this out (or at least I was able to):

' append the query string to the redirect URL
  If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
      MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
      MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
    End If
  End If

This is the code I had, deleted it - updated my record and no parameters were passed.  Hopefully this will answer at least one of your questions.

Author Comment

ID: 8471499
Code is below, apologies for the delay...  I tried to cut out the stuff that was irrelevant, but there still a good  bit.  For reference, there are two url parameters that are getting passed to this asp page, "vendor_id" and "resis_id".  After I do the submit to delete the record (or edit, I have the same issue with both), both parameters are getting bassed back to the redirect page after the submission.  I would only like to pass back one, the "vendor_id" parameter.  Thanks for any help, John.

// *** Edit Operations: declare variables

// set the form action variable
var MM_editAction = Request.ServerVariables("SCRIPT_NAME");
if (Request.QueryString) {
  MM_editAction += "?" + Request.QueryString;

// boolean to abort record edit
var MM_abortEdit = false;

// query string to execute
var MM_editQuery = "";
// *** Delete Record: declare variables

if (String(Request("MM_delete")) == "form1" &&
    String(Request("MM_recordId")) != "undefined") {

  var MM_editConnection = MM_hosted_auburn_STRING;
  var MM_editTable = "resis_data";
  var MM_editColumn = "resis_id";
  var MM_recordId = "" + Request.Form("MM_recordId") + "";
  var MM_editRedirectUrl = "resis_list.asp";

  // append the query string to the redirect URL
  if (MM_editRedirectUrl && Request.QueryString && Request.QueryString.Count > 0) {
    MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + Request.QueryString;
// *** Delete Record: construct a sql delete statement and execute it

if (String(Request("MM_delete")) != "undefined" &&
    String(Request("MM_recordId")) != "undefined") {

  // create the sql delete statement
  MM_editQuery = "delete from " + MM_editTable + " where " + MM_editColumn + " = " + MM_recordId;

  if (!MM_abortEdit) {
    // execute the delete
    var MM_editCmd = Server.CreateObject('ADODB.Command');
    MM_editCmd.ActiveConnection = MM_editConnection;
    MM_editCmd.CommandText = MM_editQuery;

    if (MM_editRedirectUrl) {

var vendor_rec__MMColParam = "1";
if (String(Request.QueryString("vendor_id")) != "undefined" && 
    String(Request.QueryString("vendor_id")) != "") {
  vendor_rec__MMColParam = String(Request.QueryString("vendor_id"));
var vendor_rec = Server.CreateObject("ADODB.Recordset");
vendor_rec.ActiveConnection = MM_hosted_auburn_STRING;
vendor_rec.Source = "SELECT vendor_id, vendor_name FROM vendor_data WHERE vendor_id = "+ vendor_rec__MMColParam.replace(/'/g, "''") + "";
vendor_rec.CursorType = 0;
vendor_rec.CursorLocation = 2;
vendor_rec.LockType = 1;
var vendor_rec_numRows = 0;
var resis_rec__MMColParam = "1";
if (String(Request.QueryString("resis_id")) != "undefined" && 
    String(Request.QueryString("resis_id")) != "") {
  resis_rec__MMColParam = String(Request.QueryString("resis_id"));
var resis_rec = Server.CreateObject("ADODB.Recordset");
resis_rec.ActiveConnection = MM_hosted_auburn_STRING;
resis_rec.Source = "SELECT r.*,r.watts*r.qty*r.h_w/1000*4.33*ec.kwh_cost as resis_op  FROM resis_data r,elec_cost ec  WHERE resis_id = "+ resis_rec__MMColParam.replace(/'/g, "''") + "";
resis_rec.CursorType = 0;
resis_rec.CursorLocation = 2;
resis_rec.LockType = 1;
var resis_rec_numRows = 0;
<% var MM_paramName = ""; %>
// *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters

// create the list of parameters which should not be maintained
var MM_removeList = "&index=";
if (MM_paramName != "") MM_removeList += "&" + MM_paramName.toLowerCase() + "=";
var MM_keepURL="",MM_keepForm="",MM_keepBoth="",MM_keepNone="";

// add the URL parameters to the MM_keepURL string
for (var items=new Enumerator(Request.QueryString); !items.atEnd(); items.moveNext()) {
  var nextItem = "&" + items.item().toLowerCase() + "=";
  if (MM_removeList.indexOf(nextItem) == -1) {
    MM_keepURL += "&" + items.item() + "=" + Server.URLencode(Request.QueryString(items.item()));

// add the Form variables to the MM_keepForm string
for (var items=new Enumerator(Request.Form); !items.atEnd(); items.moveNext()) {
  var nextItem = "&" + items.item().toLowerCase() + "=";
  if (MM_removeList.indexOf(nextItem) == -1) {
    MM_keepForm += "&" + items.item() + "=" + Server.URLencode(Request.Form(items.item()));

// create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL + MM_keepForm;
if (MM_keepBoth.length > 0) MM_keepBoth = MM_keepBoth.substring(1);
if (MM_keepURL.length > 0)  MM_keepURL = MM_keepURL.substring(1);
if (MM_keepForm.length > 0) MM_keepForm = MM_keepForm.substring(1);

    <input name="Submit" type="submit" onClick="MM_validateForm('textfield2','','R','textfield3','','RisNum','textfield4','','RisNum','textfield5','','NisNum','textfield6','','RisNum');return document.MM_returnValue" value="Delete?">
    <a href="resis_list.asp?<%= MM_keepNone + ((MM_keepNone!="")?"&":"") + "vendor_id=" + resis_rec.Fields.Item("vendor_id").Value %>">Cancel
    and Return to Vendor Detail</a> </p>
  <p><IMG SRC="charts/resis_single.asp?<%= MM_keepURL %>">
  <p> </p>
  <input type="hidden" name="MM_delete" value="form1">
  <input type="hidden" name="MM_recordId" value="<%= resis_rec.Fields.Item("resis_id").Value %>">
<p>&nbsp; </p>


Author Comment

ID: 8471651
One more thought.  What's wrong with the below code?  This should work, as I get the behavior I want (only one url parameter, vendor_id) when I setup a hyperlink this way, but I can't get the redirect url to use this.  Pardon my ignorance on this...  Thanks.

var MM_editRedirectUrl = "resis_list.asp" + <%= MM_keepNone + ((MM_keepNone!="")?"&":"") + "vendor_id=" + resis_rec.Fields.Item("vendor_id").Value %>;

I get a error of
Error Type:
Microsoft JScript compilation (0x800A03EA)
Syntax error

on the line.

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question