mwoolgar
asked on
ASP stored procedure
Hi
I'm having problems trying to get my head around how to make this stored procedure work.
My form is called full.asp - once you select an entry it will bring up all the info on that particular sale. The problem is that we have to show the sales who is responsible for the sale. These are assigned according to postcode [RepPostCode].
The stored procedure below sorts out how to show the sales person or installer according to postcode but how do I call the SP from within the asp form?
The form code is below the SP's.
cheers guys
Miles
__________________________ __________ __________ ________
Stored Procedure = sp_salesdefault
__________________________ __________ __________ _________
CREATE procedure sp_salesdefault AS SELECT
[uapID],
rtrim(ltrim( RepFirstName))+' '+ rtrim(ltrim( RepSurname)) AS SALESCONSULTANT,
rtrim(ltrim( RepFirstName))+' '+ rtrim(ltrim( RepSurname)) AS INSTALLER
FROM [UAP].[dbo].[uapForm] UF,[UAP].[dbo].[uapRepArea ] URA,
[UAP].[dbo].[uapReps] UR
WHERE SUBSTRING([PostCode],1,2) = URA.RepPostCode
and URA.RepID = UR.repID
GO
__________________________ __________ _
Form = uapForm
__________________________ __________ _
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
if session("group") = 1 then
response.redirect("/conten ts/display /full.asp? id=" & request.querystring("id"))
end if
if session("group") = 3 then
response.redirect("/conten ts/display _uap/full. asp?id=" & request.querystring("id"))
end if
if session("group") = 4 then
response.redirect("/conten ts/display _vo/full.a sp?id=" & request.querystring("id"))
end if
%>
<!--#include file="../../Connections/UA P.asp" -->
<%
' *** Edit Operations: declare variables
Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd
Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId
Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i
MM_editAction = CStr(Request.ServerVariabl es("SCRIPT _NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Update Record: set variables
If (CStr(Request("MM_update") ) = "form1" And CStr(Request("MM_recordId" )) <> "") Then
MM_editConnection = MM_UAP_STRING
MM_editTable = "dbo.uapForm"
MM_editColumn = "uapID"
MM_recordId = "" + Request.Form("MM_recordId" ) + ""
MM_editRedirectUrl = "mail.asp?id=" + postcode + ""
MM_fieldsStr = "AutoExchangeClientID|valu e"
MM_columnsStr = "AutoExchangeClientID|',no ne,''"
MM_fieldsStr = "VSReferenceNumber|value"
MM_columnsStr = "VSReferenceNumber|',none, ''"
' create the MM_fields and MM_columns arrays
MM_fields2 = Split(MM_fieldsStr2, "|")
MM_columns2 = Split(MM_columnsStr2, "|")
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")
' set the form values 2
'For MM_i = LBound(MM_fields2) To UBound(MM_fields2) Step 2
' MM_fields2(MM_i+1) = CStr(Request.Form(MM_field s2(MM_i)))
' Next
' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_field s(MM_i)))
Next
' 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
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Update Record: construct a sql update statement and execute it
If (CStr(Request("MM_update") ) <> "" And CStr(Request("MM_recordId" )) <> "") Then
' create the sql update statement
MM_editQuery = "update " & MM_editTable & " set "
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1)," ,")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","'' ") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_editQuery = MM_editQuery & ","
End If
MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
Next
MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId
If (Not MM_abortEdit) Then
' execute the update
Set MM_editCmd = Server.CreateObject("ADODB .Command")
MM_editCmd.ActiveConnectio n = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnectio n.Close
If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editR edirectUrl )
End If
End If
End If
%>
<%
Dim rsDisplayAll__MMColParam
rsDisplayAll__MMColParam = "1"
If (Request.QueryString("id") <> "") Then
rsDisplayAll__MMColParam = Request.QueryString("id")
End If
%>
<%
Dim rsDisplayAll
Dim rsDisplayAll_numRows
Set rsDisplayAll = Server.CreateObject("ADODB .Recordset ")
rsDisplayAll.ActiveConnect ion = MM_UAP_STRING
rsDisplayAll.Source = "SELECT * FROM dbo.uapForm WHERE uapID = " + Replace(rsDisplayAll__MMCo lParam, "'", "''") + ""
rsDisplayAll.CursorType = 0
rsDisplayAll.CursorLocatio n = 2
rsDisplayAll.LockType = 1
rsDisplayAll.Open()
rsDisplayAll_numRows = 0
%>
<html>
<head>
<title>UAP Logging System</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="/design/style.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(p arseInt(ap pVersion)= =4)) {
document.MM_pgW=innerWidth ; document.MM_pgH=innerHeigh t; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_p gW || innerHeight!=document.MM_p gH) location.reload();
}
MM_reloadPage(true);
function MM_openBrWindow(theURL,win Name,featu res) { //v2.0
window.open(theURL,winName ,features) ;
}
//-->
</script>
</head>
<body>
<!-- #include virtual ="/design/includes/header. asp" -->
<p> </p>
<p> </p>
<div style="position: absolute; left: 10px; width: 25%">
<iframe width="100%" height="500" src="../display/notes.asp? id=<%=(rsD isplayAll. Fields.Ite m("uapID") .Value)%>" style="position: relative;"></iframe>
</div>
<%
MM_editAction = MM_editAction & "&postcode=" & rsDisplayAll.Fields.Item(" PostCode") .Value
%>
<form ACTION="<%=MM_editAction%> " METHOD="POST" name="form1">
<table width="40%" border="0" align="center" cellpadding="0" cellspacing="5">
<tr>
<td colspan="2"><strong>Contac t Details</strong></td>
</tr>
<tr>
<td align="right">Dealership Name:</td>
<td><%=(rsDisplayAll.Field s.Item("De alershipNa me").Value )%></td>
</tr>
<tr>
<td align="right">Trading Name:</td>
<td><%=(rsDisplayAll.Field s.Item("Tr adingName" ).Value)%> </td>
</tr>
<tr>
<td align="right">Sales Contact:</td>
<td><%=(rsDisplayAll.Field s.Item("Sa lesContact ").Value)% > </td>
</tr>
<tr>
<td align="right">Address:</td >
<td><%=(rsDisplayAll.Field s.Item("Ad dress").Va lue)%> </td>
</tr>
<tr>
<td align="right">Town:</td>
<td><%=(rsDisplayAll.Field s.Item("To wn").Value )%> </td>
</tr>
<tr>
<td align="right">County:</td>
<td><%=(rsDisplayAll.Field s.Item("Co unty").Val ue)%> </td>
</tr>
<tr>
<td align="right">Post Code:</td>
<td><%=(rsDisplayAll.Field s.Item("Po stCode").V alue)%> </td>
</tr>
<tr>
<td align="right">Phone Number:</td>
<td><%=(rsDisplayAll.Field s.Item("Ph oneNumber" ).Value)%> </td>
</tr>
<tr>
<td align="right">Fax Number:</td>
<td><%=(rsDisplayAll.Field s.Item("Fa xNumber"). Value)%> </td>
</tr>
<tr>
<td align="right">E-mail:</td>
<td><%=(rsDisplayAll.Field s.Item("Em ail").Valu e)%> </td>
</tr>
<tr>
<td align="right" valign="top">Enquiry Form Preference:</td>
<td><%
if (rsDisplayAll.Fields.Item( "EnqFormPr ef").Value ) = "False" then
Response.Write("Fax")
else
if Trim(rsDisplayAll.Fields.I tem("EnqFo rmPref").V alue) = "True" then
Response.Write("Email")
else
end if
end if
%> </td>
</tr>
<tr>
<td align="right">Web Address:</td>
<td><%=(rsDisplayAll.Field s.Item("We bAddress") .Value)%> </td>
</tr>
<tr>
<td align="right" valign="top">Franchises:</ td>
<td><%=(rsDisplayAll.Field s.Item("Fr anchises") .Value)%>< /td>
</tr>
<tr>
<td align="right" valign="top">Services:</td >
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>New Sales:</td>
<td>
<input <%If (CStr((rsDisplayAll.Fields .Item("Ser vs_New").V alue)) = CStr("True")) Then Response.Write("checked") : Response.Write("")%> name="Servs_New" type="checkbox" id="Servs_New" value="1" disabled="disabled">
</td>
</tr>
<tr>
<td>Used Sales:</td>
<td>
<input <%If (CStr((rsDisplayAll.Fields .Item("Ser vs_Used"). Value)) = CStr("True")) Then Response.Write("checked") : Response.Write("")%> name="Servs_Used" type="checkbox" id="Servs_Used" value="1" disabled="disabled">
</td>
</tr>
<tr>
<td>Service:</td>
<td>
<input <%If (CStr((rsDisplayAll.Fields .Item("Ser vs_Service ").Value)) = CStr("True")) Then Response.Write("checked") : Response.Write("")%> name="Servs_Service" type="checkbox" id="Servs_Service" value="1" disabled="disabled">
</td>
</tr>
<tr>
<td>Body Shop:</td>
<td>
<input <%If (CStr((rsDisplayAll.Fields .Item("Ser vs_BodySho p").Value) ) = CStr("True")) Then Response.Write("checked") : Response.Write("")%> name="Servs_BodyShop" type="checkbox" id="Servs_BodyShop" value="1" disabled="disabled">
</td>
</tr>
<tr>
<td>Parts:</td>
<td>
<input <%If (CStr((rsDisplayAll.Fields .Item("Ser vs_Parts") .Value)) = CStr("True")) Then Response.Write("checked") : Response.Write("")%> name="Servs_Parts" type="checkbox" id="Servs_Parts" value="1" disabled="disabled">
</td>
</tr>
<tr>
<td>Showroom:</td>
<td>
<input <%If (CStr((rsDisplayAll.Fields .Item("Ser vs_Showroo m").Value) ) = CStr("True")) Then Response.Write("checked") : Response.Write("")%> name="Servs_Showroom" type="checkbox" id="Servs_Showroom" value="1" disabled="disabled">
</td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2"><hr></td>
</tr>
</table>
<table width="40%" border="0" align="center" cellpadding="0" cellspacing="5">
<tr>
<td colspan="4"><strong>PC Minimum Requirements</strong></td>
</tr>
<tr>
<td colspan="4"><em>Does the computer that will run Trader Desk have the
following minimum requirements?</em></td>
</tr>
<tr>
<td align="right"> </td>
<td>Yes</td>
<td>No</td>
<td>Help</td>
</tr>
<tr>
<td>300 MHz Processor </td>
<td><input <%If (CStr((rsDisplayAll.Fields .Item("PC_ Proc").Val ue)) = CStr("True")) Then Response.Write("CHECKED") : Response.Write("")%> type="radio" name="PC_Proc" value="1" disabled="disabled"></td>
<td> <input <%If (CStr((rsDisplayAll.Fields .Item("PC_ Proc").Val ue)) = CStr("False")) Then Response.Write("CHECKED") : Response.Write("")%> type="radio" name="PC_Proc" value="0" disabled="disabled"></td>
<td align="center"><strong><a onclick="helpText(content[ 0], m1);" style="cursor: help;">?</a></strong></td>
</tr>
<tr>
<td>64 MB RAM </td>
<td><input <%If (CStr((rsDisplayAll.Fields .Item("PC_ RAM").Valu e)) = CStr("True")) Then Response.Write("CHECKED") : Response.Write("")%> type="radio" name="PC_RAM" value="1" disabled="disabled"></td>
<td> <input <%If (CStr((rsDisplayAll.Fields .Item("PC_ RAM").Valu e)) = CStr("False")) Then Response.Write("CHECKED") : Response.Write("")%> type="radio" name="PC_RAM" value="0" disabled="disabled"></td>
<td align="center"><strong><a onclick="helpText(content[ 1], m1);" style="cursor: help;">?</a></strong></td>
</tr>
<tr>
<td>500 MB Free Hard Disk Space </td>
<td><input <%If (CStr((rsDisplayAll.Fields .Item("PC_ DiskSpace" ).Value)) = CStr("True")) Then Response.Write("CHECKED") : Response.Write("")%> type="radio" name="PC_DiskSpace" value="1" disabled="disabled"></td>
<td> <input <%If (CStr((rsDisplayAll.Fields .Item("PC_ DiskSpace" ).Value)) = CStr("False")) Then Response.Write("CHECKED") : Response.Write("")%> type="radio" name="PC_DiskSpace" value="0" disabled="disabled"></td>
<td align="center"><strong><a onclick="helpText(content[ 2], m1);" style="cursor: help;">?</a></strong></td>
</tr>
<tr>
<td>800x600 16 bit Colour Monitor </td>
<td><input <%If (CStr((rsDisplayAll.Fields .Item("PC_ Resolution ").Value)) = CStr("True")) Then Response.Write("CHECKED") : Response.Write("")%> type="radio" name="PC_Resolution" value="1" disabled="disabled"></td>
<td> <input <%If (CStr((rsDisplayAll.Fields .Item("PC_ Resolution ").Value)) = CStr("False")) Then Response.Write("CHECKED") : Response.Write("")%> type="radio" name="PC_Resolution" value="0" disabled="disabled"></td>
<td align="center"><strong><a onclick="helpText(content[ 3], m1);" style="cursor: help;">?</a></strong></td>
</tr>
<tr>
<td>16 Speed CD ROM Drive </td>
<td><input <%If (CStr((rsDisplayAll.Fields .Item("PC_ CD").Value )) = CStr("True")) Then Response.Write("CHECKED") : Response.Write("")%> type="radio" name="PC_CD" value="1" disabled="disabled"></td>
<td> <input <%If (CStr((rsDisplayAll.Fields .Item("PC_ CD").Value )) = CStr("False")) Then Response.Write("CHECKED") : Response.Write("")%> type="radio" name="PC_CD" value="0" disabled="disabled"></td>
<td align="center"> </td>
</tr>
<tr>
<td>56K modem and phone line and/or Internet connection </td>
<td><input <%If (CStr((rsDisplayAll.Fields .Item("PC_ Modem").Va lue)) = CStr("True")) Then Response.Write("CHECKED") : Response.Write("")%> type="radio" name="PC_Modem" value="1" disabled="disabled"></td>
<td> <input <%If (CStr((rsDisplayAll.Fields .Item("PC_ Modem").Va lue)) = CStr("False")) Then Response.Write("CHECKED") : Response.Write("")%> type="radio" name="PC_Modem" value="0" disabled="disabled"></td>
<td align="center"> </td>
</tr>
<tr align="center">
<td colspan="4"><span id="m1" style="font-weight: bold;"> </span></td>
</tr>
<tr>
<td colspan="4"><hr></td>
</tr>
</table>
<table width="40%" border="0" align="center" cellpadding="0" cellspacing="5">
<tr>
<td colspan="4"><strong>Intern et Connection</strong></td>
</tr>
<tr>
<td colspan="4"><em>Does the computer that Trader Desk will be installed
on:</em></td>
</tr>
<tr>
<td> </td>
<td align="center">Yes</td>
<td align="center">No</td>
<td align="center">Help</td>
</tr>
<tr>
<td>Have connection to the Internet? (NOT via your manufacturer) </td>
<td align="center"><input <%If (CStr((rsDisplayAll.Fields .Item("Int ernet_Have Con").Valu e)) = CStr("True")) Then Response.Write("CHECKED") : Response.Write("")%> type="radio" name="Internet_HaveCon" value="1" disabled="disabled">
</td>
<td align="center"> <input <%If (CStr((rsDisplayAll.Fields .Item("Int ernet_Have Con").Valu e)) = CStr("False")) Then Response.Write("CHECKED") : Response.Write("")%> type="radio" name="Internet_HaveCon" value="0" disabled="disabled">
</td>
<td align="center"><strong><a onclick="helpText(content[ 4], m2);" style="cursor: help;">?</a></strong></td>
</tr>
<tr>
<td>What Internet Service Provider do you use at present?</td>
<td colspan="3" align="center"><%=(rsDispl ayAll.Fiel ds.Item("I nternet_IS P").Value) %>
</td>
</tr>
<tr>
<td>Do you know your Username and Password of your Internet connection?</td>
<td align="center"><input <%If (CStr((rsDisplayAll.Fields .Item("Int ernet_User Pass").Val ue)) = CStr("True")) Then Response.Write("CHECKED") : Response.Write("")%> type="radio" name="Internet_UserPass" value="1" disabled="disabled">
</td>
<td align="center"> <input <%If (CStr((rsDisplayAll.Fields .Item("Int ernet_User Pass").Val ue)) = CStr("False")) Then Response.Write("CHECKED") : Response.Write("")%> type="radio" name="Internet_UserPass" value="0" disabled="disabled">
</td>
<td align="center"><strong><a onclick="helpText(content[ 5], m2);" style="cursor: help;">?</a></strong></td>
</tr>
<tr>
<td>Is the connection via an independent ISDN/ADSL Line?</td>
<td colspan="3" align="center"><%=(rsDispl ayAll.Fiel ds.Item("I nternet_IS DN").Value )%>
</td>
</tr>
<tr>
<td>Is the connection via a modem (min 56k recommended) with phone line</td>
<td align="center"><input <%If (CStr((rsDisplayAll.Fields .Item("Int ernet_Mode m").Value) ) = CStr("True")) Then Response.Write("CHECKED") : Response.Write("")%> type="radio" name="Internet_Modem" value="1" disabled="disabled">
</td>
<td align="center"> <input <%If (CStr((rsDisplayAll.Fields .Item("Int ernet_Mode m").Value) ) = CStr("False")) Then Response.Write("CHECKED") : Response.Write("")%> type="radio" name="Internet_Modem" value="0" disabled="disabled">
</td>
<td align="center"> </td>
</tr>
<tr>
<td>Is the connection via a Network? (see question 3)</td>
<td align="center"><input <%If (CStr((rsDisplayAll.Fields .Item("Int ernet_Netw ork").Valu e)) = CStr("True")) Then Response.Write("CHECKED") : Response.Write("")%> name="Internet_Network" type="radio" value="1" disabled="disabled">
</td>
<td align="center"> <input <%If (CStr((rsDisplayAll.Fields .Item("Int ernet_Netw ork").Valu e)) = CStr("False")) Then Response.Write("CHECKED") : Response.Write("")%> name="Internet_Network" type="radio" value="0" disabled="disabled">
</td>
<td align="center"> </td>
</tr>
<tr>
<td>Do you use AOL or CompuServe to connect to the Internet?</td>
<td align="center"><input <%If (CStr((rsDisplayAll.Fields .Item("Int ernet_AOL" ).Value)) = CStr("True")) Then Response.Write("CHECKED") : Response.Write("")%> type="radio" name="Internet_AOL" value="1" disabled="disabled">
</td>
<td align="center"> <input <%If (CStr((rsDisplayAll.Fields .Item("Int ernet_AOL" ).Value)) = CStr("False")) Then Response.Write("CHECKED") : Response.Write("")%> type="radio" name="Internet_AOL" value="0" disabled="disabled">
</td>
<td align="center"> </td>
</tr>
<tr>
<td colspan="4"><em>AOL 5 and CompuServe CANNOT be used as your ISP when
using Trader Desk. We can supply an alternative ISP to you at no extra
cost.</em></td>
</tr>
<tr>
<td colspan="4"><span id="m2" style="font-weight: bold;"> </span></td>
</tr>
<tr>
<td colspan="4"><hr></td>
</tr>
</table>
<table width="40%" border="0" align="center" cellpadding="0" cellspacing="5">
<tr>
<td colspan="4"><strong>Networ k Internet Connection</strong></td>
</tr>
<tr>
<td colspan="4"><em>If your connection is via a network:</em></td>
</tr>
<tr>
<td> </td>
<td align="center">Yes</td>
<td align="center">No</td>
<td align="center">Help</td>
</tr>
<tr>
<td>Is the connection via a Proxy Server?</td>
<td align="center"><input <%If (CStr((rsDisplayAll.Fields .Item("Net Int_Proxy" ).Value)) = CStr("True")) Then Response.Write("CHECKED") : Response.Write("")%> type="radio" name="NetInt_Proxy" value="1" disabled="disabled">
</td>
<td align="center"> <input <%If (CStr((rsDisplayAll.Fields .Item("Net Int_Proxy" ).Value)) = CStr("False")) Then Response.Write("CHECKED") : Response.Write("")%> type="radio" name="NetInt_Proxy" value="0" disabled="disabled">
</td>
<td align="center"> </td>
</tr>
<tr>
<td>If YES, please state which one, for example: Microsoft </td>
<td colspan="3" align="center"><%=(rsDispl ayAll.Fiel ds.Item("N etInt_Prov ider").Val ue)%>
</td>
</tr>
<tr>
<td>If YES, are the TCP/IP ports 21 and 1433 enabled for incoming and outgoing
traffic?</td>
<td align="center"><input <%If (CStr((rsDisplayAll.Fields .Item("Net Int_Ports" ).Value)) = CStr("True")) Then Response.Write("CHECKED") : Response.Write("")%> type="radio" name="NetInt_Ports" value="1" disabled="disabled">
</td>
<td align="center"> <input <%If (CStr((rsDisplayAll.Fields .Item("Net Int_Ports" ).Value)) = CStr("False")) Then Response.Write("CHECKED") : Response.Write("")%> type="radio" name="NetInt_Ports" value="0" disabled="disabled">
</td>
<td align="center"> </td>
</tr>
<tr>
<td colspan="4"><em>A proxy server makes connection to the Internet - TCP/IP
communicates through a number of channels (ports) data between the server
and the Internet. Data sent from Trader Desk to the Internet has to be
sent through ports 21 and 1433. Net Pilot only uses port 80 - and therefore
cannot send Trader Desk data.</em><br /> <br />
If you are using Brighton or a Satellite Link, please be aware that Trader
Desk CANNOT be installed under any circumstances.</td>
</tr>
<tr>
<td colspan="4"><hr></td>
</tr>
</table>
<table width="40%" border="0" align="center" cellpadding="0" cellspacing="5">
<tr>
<td colspan="4"><strong>Machin e Ownership</strong></td>
</tr>
<tr>
<td align="right"> </td>
<td>Yes</td>
<td>No</td>
<td> </td>
</tr>
<tr>
<td>Do you own the machine(s) that will be used to run Trader Desk?</td>
<td><input <%If (CStr((rsDisplayAll.Fields .Item("Own ership_Own ").Value)) = CStr("True")) Then Response.Write("CHECKED") : Response.Write("")%> type="radio" name="Ownership_Own" value="1" disabled="disabled"></td>
<td> <input <%If (CStr((rsDisplayAll.Fields .Item("Own ership_Own ").Value)) = CStr("False")) Then Response.Write("CHECKED") : Response.Write("")%> type="radio" name="Ownership_Own" value="0" disabled="disabled"></td>
<td align="center"> </td>
</tr>
<tr>
<td>If NO, have you been given the authority to put other software on the
machine?</td>
<td><input <%If (CStr((rsDisplayAll.Fields .Item("Own ership_Aut hority").V alue)) = CStr("True")) Then Response.Write("CHECKED") : Response.Write("")%> type="radio" name="Ownership_Authority" value="1" disabled="disabled"></td>
<td> <input <%If (CStr((rsDisplayAll.Fields .Item("Own ership_Aut hority").V alue)) = CStr("False")) Then Response.Write("CHECKED") : Response.Write("")%> type="radio" name="Ownership_Authority" value="0" disabled="disabled"></td>
<td align="center"> </td>
</tr>
<tr>
<td colspan="4"><hr></td>
</tr>
</table>
<table width="40%" border="0" align="center" cellpadding="0" cellspacing="5">
<tr>
<td colspan="4"><strong>Window s Operating System</strong></td>
</tr>
<tr>
<td align="right"> </td>
<td align="center">Yes</td>
<td align="center">No</td>
<td align="center">Help</td>
</tr>
<tr>
<td>What operating system is on the machine(s) that will run Trader Desk?
For Example: Windows 98/95/ME/NT4/2000/XP</td>
<td colspan="3" align="center"><%=(rsDispl ayAll.Fiel ds.Item("W indows_OS" ).Value)%>
</td>
</tr>
<tr>
<td>If Trader Desk is to be installed onto a Windows NT4/2000/XP server
or workstation, have you given the user(s) of Trader Desk admin rights
for their local machine(s)?</td>
<td align="center"> <input type="radio" name="Windows_Admin" value="1" disabled="disabled"></td>
<td align="center">
<input type="radio" name="Windows_Admin" value="0" disabled="disabled"></td>
<td align="center"><strong><a onclick="helpText(content[ 6], m3);" style="cursor: help;">?</a></strong></td>
</tr>
<tr>
<td colspan="4"><span id="m3" style="font-weight: bold;"> </span></td>
</tr>
<tr>
<td colspan="4"><hr></td>
</tr>
<tr align="center">
<td colspan="4"><a href="dms_popup.htm" target="_blank" onClick="MM_openBrWindow(' dms_popup. htm','uapo p','scroll bars=yes,r esizable=y es,width=5 50,height= 350'); return false;">View
DMS Details</a></td>
</tr>
</table>
<table width="40%" border="0" align="center" cellpadding="0" cellspacing="5">
<tr>
<td width="50%" align="right">Signed by:</td>
<td width="50%"><%=(rsDisplayA ll.Fields. Item("Sign edBy").Val ue)%> </td>
</tr>
<tr>
<td width="50%" align="right">Date (dd/mm/yyyy):</td>
<td width="50%"><%=(rsDisplayA ll.Fields. Item("Sign edDate").V alue)%> </td>
</tr>
<tr>
<td colspan="2"><hr></td>
</tr>
</table>
<table width="40%" border="0" align="center" cellpadding="0" cellspacing="5">
<tr>
<td width="50%" align="right">Sales Consultant:</td>
<td> <input name="SalesConsultant" type="text" disabled="disabled" id="SalesConsultant" value="<%= Trim((rsDisplayAll.Fields. Item("Sale sConsultan t").Value) ) %>"></td>
</tr>
<tr>
<td width="50%" align="right">Installer:</ td>
<td> <input name="Installer" type="text" disabled="disabled" id="Installer" value="<%= Trim((rsDisplayAll.Fields. Item("Inst aller").Va lue)) %>"></td>
</tr>
<tr>
<td align="right">Installation Date:</td>
<td> <input name="InstallationDate" type="text" disabled="disabled" id="InstallationDate" value="<%= Trim((rsDisplayAll.Fields. Item("Inst allationDa te").Value )) %>"></td>
</tr>
<tr>
<td width="50%" align="right"> VS Ref Number:</td>
<td> <input name="VSReferenceNumber" disabled="disabled" type="text" id="VSReferenceNumber" value="<%= Trim((rsDisplayAll.Fields. Item("VSRe ferenceNum ber").Valu e)) %>">
</td>
</tr>
<tr>
<td align="center"><div align="right">AutoExchange ClientID<b r>
<br>
</div></td>
<td align="center"> <div align="left">
<input name="AutoExchangeClientID " disabled="disabled" type="text" value="<%= Trim((rsDisplayAll.Fields. Item("Auto ExchangeCl ientID").V alue))%>">
<input type="hidden" name="postcode" id="postcode" value="<%=(rsDisplayAll.Fi elds.Item( "PostCode" ).Value)%> ">
</div></td>
</tr>
<tr>
<td align="center"><input type="submit" name="Submit" value="Submit" class="button"></td>
<td align="center"><a href="edit.aspx" target="_blank">edit VS Ref Number<br> or AutoExchangeClientID</a> </td>
</tr>
</table>
<p> </p>
<input type="hidden" name="MM_insert" value="form1">
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="MM_recordId" value="<%= rsDisplayAll.Fields.Item(" uapID").Va lue %>">
</form>
<p> </p>
<p>
<!-- #include virtual ="/design/includes/footer. asp" -->
</p>
</body>
</html>
<%
rsDisplayAll.Close()
Set rsDisplayAll = Nothing
%>
I'm having problems trying to get my head around how to make this stored procedure work.
My form is called full.asp - once you select an entry it will bring up all the info on that particular sale. The problem is that we have to show the sales who is responsible for the sale. These are assigned according to postcode [RepPostCode].
The stored procedure below sorts out how to show the sales person or installer according to postcode but how do I call the SP from within the asp form?
The form code is below the SP's.
cheers guys
Miles
__________________________
Stored Procedure = sp_salesdefault
__________________________
CREATE procedure sp_salesdefault AS SELECT
[uapID],
rtrim(ltrim( RepFirstName))+' '+ rtrim(ltrim( RepSurname)) AS SALESCONSULTANT,
rtrim(ltrim( RepFirstName))+' '+ rtrim(ltrim( RepSurname)) AS INSTALLER
FROM [UAP].[dbo].[uapForm] UF,[UAP].[dbo].[uapRepArea
[UAP].[dbo].[uapReps] UR
WHERE SUBSTRING([PostCode],1,2) = URA.RepPostCode
and URA.RepID = UR.repID
GO
__________________________
Form = uapForm
__________________________
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
if session("group") = 1 then
response.redirect("/conten
end if
if session("group") = 3 then
response.redirect("/conten
end if
if session("group") = 4 then
response.redirect("/conten
end if
%>
<!--#include file="../../Connections/UA
<%
' *** Edit Operations: declare variables
Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd
Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId
Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i
MM_editAction = CStr(Request.ServerVariabl
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Update Record: set variables
If (CStr(Request("MM_update")
MM_editConnection = MM_UAP_STRING
MM_editTable = "dbo.uapForm"
MM_editColumn = "uapID"
MM_recordId = "" + Request.Form("MM_recordId"
MM_editRedirectUrl = "mail.asp?id=" + postcode + ""
MM_fieldsStr = "AutoExchangeClientID|valu
MM_columnsStr = "AutoExchangeClientID|',no
MM_fieldsStr = "VSReferenceNumber|value"
MM_columnsStr = "VSReferenceNumber|',none,
' create the MM_fields and MM_columns arrays
MM_fields2 = Split(MM_fieldsStr2, "|")
MM_columns2 = Split(MM_columnsStr2, "|")
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")
' set the form values 2
'For MM_i = LBound(MM_fields2) To UBound(MM_fields2) Step 2
' MM_fields2(MM_i+1) = CStr(Request.Form(MM_field
' Next
' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_field
Next
' 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
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Update Record: construct a sql update statement and execute it
If (CStr(Request("MM_update")
' create the sql update statement
MM_editQuery = "update " & MM_editTable & " set "
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),"
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_editQuery = MM_editQuery & ","
End If
MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
Next
MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId
If (Not MM_abortEdit) Then
' execute the update
Set MM_editCmd = Server.CreateObject("ADODB
MM_editCmd.ActiveConnectio
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnectio
If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editR
End If
End If
End If
%>
<%
Dim rsDisplayAll__MMColParam
rsDisplayAll__MMColParam = "1"
If (Request.QueryString("id")
rsDisplayAll__MMColParam = Request.QueryString("id")
End If
%>
<%
Dim rsDisplayAll
Dim rsDisplayAll_numRows
Set rsDisplayAll = Server.CreateObject("ADODB
rsDisplayAll.ActiveConnect
rsDisplayAll.Source = "SELECT * FROM dbo.uapForm WHERE uapID = " + Replace(rsDisplayAll__MMCo
rsDisplayAll.CursorType = 0
rsDisplayAll.CursorLocatio
rsDisplayAll.LockType = 1
rsDisplayAll.Open()
rsDisplayAll_numRows = 0
%>
<html>
<head>
<title>UAP Logging System</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="/design/style.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(p
document.MM_pgW=innerWidth
else if (innerWidth!=document.MM_p
}
MM_reloadPage(true);
function MM_openBrWindow(theURL,win
window.open(theURL,winName
}
//-->
</script>
</head>
<body>
<!-- #include virtual ="/design/includes/header.
<p> </p>
<p> </p>
<div style="position: absolute; left: 10px; width: 25%">
<iframe width="100%" height="500" src="../display/notes.asp?
</div>
<%
MM_editAction = MM_editAction & "&postcode=" & rsDisplayAll.Fields.Item("
%>
<form ACTION="<%=MM_editAction%>
<table width="40%" border="0" align="center" cellpadding="0" cellspacing="5">
<tr>
<td colspan="2"><strong>Contac
</tr>
<tr>
<td align="right">Dealership Name:</td>
<td><%=(rsDisplayAll.Field
</tr>
<tr>
<td align="right">Trading Name:</td>
<td><%=(rsDisplayAll.Field
</tr>
<tr>
<td align="right">Sales Contact:</td>
<td><%=(rsDisplayAll.Field
</tr>
<tr>
<td align="right">Address:</td
<td><%=(rsDisplayAll.Field
</tr>
<tr>
<td align="right">Town:</td>
<td><%=(rsDisplayAll.Field
</tr>
<tr>
<td align="right">County:</td>
<td><%=(rsDisplayAll.Field
</tr>
<tr>
<td align="right">Post Code:</td>
<td><%=(rsDisplayAll.Field
</tr>
<tr>
<td align="right">Phone Number:</td>
<td><%=(rsDisplayAll.Field
</tr>
<tr>
<td align="right">Fax Number:</td>
<td><%=(rsDisplayAll.Field
</tr>
<tr>
<td align="right">E-mail:</td>
<td><%=(rsDisplayAll.Field
</tr>
<tr>
<td align="right" valign="top">Enquiry Form Preference:</td>
<td><%
if (rsDisplayAll.Fields.Item(
Response.Write("Fax")
else
if Trim(rsDisplayAll.Fields.I
Response.Write("Email")
else
end if
end if
%> </td>
</tr>
<tr>
<td align="right">Web Address:</td>
<td><%=(rsDisplayAll.Field
</tr>
<tr>
<td align="right" valign="top">Franchises:</
<td><%=(rsDisplayAll.Field
</tr>
<tr>
<td align="right" valign="top">Services:</td
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>New Sales:</td>
<td>
<input <%If (CStr((rsDisplayAll.Fields
</td>
</tr>
<tr>
<td>Used Sales:</td>
<td>
<input <%If (CStr((rsDisplayAll.Fields
</td>
</tr>
<tr>
<td>Service:</td>
<td>
<input <%If (CStr((rsDisplayAll.Fields
</td>
</tr>
<tr>
<td>Body Shop:</td>
<td>
<input <%If (CStr((rsDisplayAll.Fields
</td>
</tr>
<tr>
<td>Parts:</td>
<td>
<input <%If (CStr((rsDisplayAll.Fields
</td>
</tr>
<tr>
<td>Showroom:</td>
<td>
<input <%If (CStr((rsDisplayAll.Fields
</td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2"><hr></td>
</tr>
</table>
<table width="40%" border="0" align="center" cellpadding="0" cellspacing="5">
<tr>
<td colspan="4"><strong>PC Minimum Requirements</strong></td>
</tr>
<tr>
<td colspan="4"><em>Does the computer that will run Trader Desk have the
following minimum requirements?</em></td>
</tr>
<tr>
<td align="right"> </td>
<td>Yes</td>
<td>No</td>
<td>Help</td>
</tr>
<tr>
<td>300 MHz Processor </td>
<td><input <%If (CStr((rsDisplayAll.Fields
<td> <input <%If (CStr((rsDisplayAll.Fields
<td align="center"><strong><a onclick="helpText(content[
</tr>
<tr>
<td>64 MB RAM </td>
<td><input <%If (CStr((rsDisplayAll.Fields
<td> <input <%If (CStr((rsDisplayAll.Fields
<td align="center"><strong><a onclick="helpText(content[
</tr>
<tr>
<td>500 MB Free Hard Disk Space </td>
<td><input <%If (CStr((rsDisplayAll.Fields
<td> <input <%If (CStr((rsDisplayAll.Fields
<td align="center"><strong><a onclick="helpText(content[
</tr>
<tr>
<td>800x600 16 bit Colour Monitor </td>
<td><input <%If (CStr((rsDisplayAll.Fields
<td> <input <%If (CStr((rsDisplayAll.Fields
<td align="center"><strong><a onclick="helpText(content[
</tr>
<tr>
<td>16 Speed CD ROM Drive </td>
<td><input <%If (CStr((rsDisplayAll.Fields
<td> <input <%If (CStr((rsDisplayAll.Fields
<td align="center"> </td>
</tr>
<tr>
<td>56K modem and phone line and/or Internet connection </td>
<td><input <%If (CStr((rsDisplayAll.Fields
<td> <input <%If (CStr((rsDisplayAll.Fields
<td align="center"> </td>
</tr>
<tr align="center">
<td colspan="4"><span id="m1" style="font-weight: bold;"> </span></td>
</tr>
<tr>
<td colspan="4"><hr></td>
</tr>
</table>
<table width="40%" border="0" align="center" cellpadding="0" cellspacing="5">
<tr>
<td colspan="4"><strong>Intern
</tr>
<tr>
<td colspan="4"><em>Does the computer that Trader Desk will be installed
on:</em></td>
</tr>
<tr>
<td> </td>
<td align="center">Yes</td>
<td align="center">No</td>
<td align="center">Help</td>
</tr>
<tr>
<td>Have connection to the Internet? (NOT via your manufacturer) </td>
<td align="center"><input <%If (CStr((rsDisplayAll.Fields
</td>
<td align="center"> <input <%If (CStr((rsDisplayAll.Fields
</td>
<td align="center"><strong><a onclick="helpText(content[
</tr>
<tr>
<td>What Internet Service Provider do you use at present?</td>
<td colspan="3" align="center"><%=(rsDispl
</td>
</tr>
<tr>
<td>Do you know your Username and Password of your Internet connection?</td>
<td align="center"><input <%If (CStr((rsDisplayAll.Fields
</td>
<td align="center"> <input <%If (CStr((rsDisplayAll.Fields
</td>
<td align="center"><strong><a onclick="helpText(content[
</tr>
<tr>
<td>Is the connection via an independent ISDN/ADSL Line?</td>
<td colspan="3" align="center"><%=(rsDispl
</td>
</tr>
<tr>
<td>Is the connection via a modem (min 56k recommended) with phone line</td>
<td align="center"><input <%If (CStr((rsDisplayAll.Fields
</td>
<td align="center"> <input <%If (CStr((rsDisplayAll.Fields
</td>
<td align="center"> </td>
</tr>
<tr>
<td>Is the connection via a Network? (see question 3)</td>
<td align="center"><input <%If (CStr((rsDisplayAll.Fields
</td>
<td align="center"> <input <%If (CStr((rsDisplayAll.Fields
</td>
<td align="center"> </td>
</tr>
<tr>
<td>Do you use AOL or CompuServe to connect to the Internet?</td>
<td align="center"><input <%If (CStr((rsDisplayAll.Fields
</td>
<td align="center"> <input <%If (CStr((rsDisplayAll.Fields
</td>
<td align="center"> </td>
</tr>
<tr>
<td colspan="4"><em>AOL 5 and CompuServe CANNOT be used as your ISP when
using Trader Desk. We can supply an alternative ISP to you at no extra
cost.</em></td>
</tr>
<tr>
<td colspan="4"><span id="m2" style="font-weight: bold;"> </span></td>
</tr>
<tr>
<td colspan="4"><hr></td>
</tr>
</table>
<table width="40%" border="0" align="center" cellpadding="0" cellspacing="5">
<tr>
<td colspan="4"><strong>Networ
</tr>
<tr>
<td colspan="4"><em>If your connection is via a network:</em></td>
</tr>
<tr>
<td> </td>
<td align="center">Yes</td>
<td align="center">No</td>
<td align="center">Help</td>
</tr>
<tr>
<td>Is the connection via a Proxy Server?</td>
<td align="center"><input <%If (CStr((rsDisplayAll.Fields
</td>
<td align="center"> <input <%If (CStr((rsDisplayAll.Fields
</td>
<td align="center"> </td>
</tr>
<tr>
<td>If YES, please state which one, for example: Microsoft </td>
<td colspan="3" align="center"><%=(rsDispl
</td>
</tr>
<tr>
<td>If YES, are the TCP/IP ports 21 and 1433 enabled for incoming and outgoing
traffic?</td>
<td align="center"><input <%If (CStr((rsDisplayAll.Fields
</td>
<td align="center"> <input <%If (CStr((rsDisplayAll.Fields
</td>
<td align="center"> </td>
</tr>
<tr>
<td colspan="4"><em>A proxy server makes connection to the Internet - TCP/IP
communicates through a number of channels (ports) data between the server
and the Internet. Data sent from Trader Desk to the Internet has to be
sent through ports 21 and 1433. Net Pilot only uses port 80 - and therefore
cannot send Trader Desk data.</em><br /> <br />
If you are using Brighton or a Satellite Link, please be aware that Trader
Desk CANNOT be installed under any circumstances.</td>
</tr>
<tr>
<td colspan="4"><hr></td>
</tr>
</table>
<table width="40%" border="0" align="center" cellpadding="0" cellspacing="5">
<tr>
<td colspan="4"><strong>Machin
</tr>
<tr>
<td align="right"> </td>
<td>Yes</td>
<td>No</td>
<td> </td>
</tr>
<tr>
<td>Do you own the machine(s) that will be used to run Trader Desk?</td>
<td><input <%If (CStr((rsDisplayAll.Fields
<td> <input <%If (CStr((rsDisplayAll.Fields
<td align="center"> </td>
</tr>
<tr>
<td>If NO, have you been given the authority to put other software on the
machine?</td>
<td><input <%If (CStr((rsDisplayAll.Fields
<td> <input <%If (CStr((rsDisplayAll.Fields
<td align="center"> </td>
</tr>
<tr>
<td colspan="4"><hr></td>
</tr>
</table>
<table width="40%" border="0" align="center" cellpadding="0" cellspacing="5">
<tr>
<td colspan="4"><strong>Window
</tr>
<tr>
<td align="right"> </td>
<td align="center">Yes</td>
<td align="center">No</td>
<td align="center">Help</td>
</tr>
<tr>
<td>What operating system is on the machine(s) that will run Trader Desk?
For Example: Windows 98/95/ME/NT4/2000/XP</td>
<td colspan="3" align="center"><%=(rsDispl
</td>
</tr>
<tr>
<td>If Trader Desk is to be installed onto a Windows NT4/2000/XP server
or workstation, have you given the user(s) of Trader Desk admin rights
for their local machine(s)?</td>
<td align="center"> <input type="radio" name="Windows_Admin" value="1" disabled="disabled"></td>
<td align="center">
<input type="radio" name="Windows_Admin" value="0" disabled="disabled"></td>
<td align="center"><strong><a onclick="helpText(content[
</tr>
<tr>
<td colspan="4"><span id="m3" style="font-weight: bold;"> </span></td>
</tr>
<tr>
<td colspan="4"><hr></td>
</tr>
<tr align="center">
<td colspan="4"><a href="dms_popup.htm" target="_blank" onClick="MM_openBrWindow('
DMS Details</a></td>
</tr>
</table>
<table width="40%" border="0" align="center" cellpadding="0" cellspacing="5">
<tr>
<td width="50%" align="right">Signed by:</td>
<td width="50%"><%=(rsDisplayA
</tr>
<tr>
<td width="50%" align="right">Date (dd/mm/yyyy):</td>
<td width="50%"><%=(rsDisplayA
</tr>
<tr>
<td colspan="2"><hr></td>
</tr>
</table>
<table width="40%" border="0" align="center" cellpadding="0" cellspacing="5">
<tr>
<td width="50%" align="right">Sales Consultant:</td>
<td> <input name="SalesConsultant" type="text" disabled="disabled" id="SalesConsultant" value="<%= Trim((rsDisplayAll.Fields.
</tr>
<tr>
<td width="50%" align="right">Installer:</
<td> <input name="Installer" type="text" disabled="disabled" id="Installer" value="<%= Trim((rsDisplayAll.Fields.
</tr>
<tr>
<td align="right">Installation
<td> <input name="InstallationDate" type="text" disabled="disabled" id="InstallationDate" value="<%= Trim((rsDisplayAll.Fields.
</tr>
<tr>
<td width="50%" align="right"> VS Ref Number:</td>
<td> <input name="VSReferenceNumber" disabled="disabled" type="text" id="VSReferenceNumber" value="<%= Trim((rsDisplayAll.Fields.
</td>
</tr>
<tr>
<td align="center"><div align="right">AutoExchange
<br>
</div></td>
<td align="center"> <div align="left">
<input name="AutoExchangeClientID
<input type="hidden" name="postcode" id="postcode" value="<%=(rsDisplayAll.Fi
</div></td>
</tr>
<tr>
<td align="center"><input type="submit" name="Submit" value="Submit" class="button"></td>
<td align="center"><a href="edit.aspx" target="_blank">edit VS Ref Number<br> or AutoExchangeClientID</a> </td>
</tr>
</table>
<p> </p>
<input type="hidden" name="MM_insert" value="form1">
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="MM_recordId" value="<%= rsDisplayAll.Fields.Item("
</form>
<p> </p>
<p>
<!-- #include virtual ="/design/includes/footer.
</p>
</body>
</html>
<%
rsDisplayAll.Close()
Set rsDisplayAll = Nothing
%>
ASKER
Thanks Lgawlik
I can see the logic in this. However, I get an error because I'm trying to show everything in uapForm as well as the salesconsultant or installer related to that id.
This is what I put into my code to replace the old one:
rsDisplayAll.Source = "SELECT uapID, SALESCONSULTANT, INSTALLER FROM dbo.v_SalesDefault WHERE uapID = " + Replace(rsDisplayAll__MMCo lParam, "'", "''") + ""
Thanks
I can see the logic in this. However, I get an error because I'm trying to show everything in uapForm as well as the salesconsultant or installer related to that id.
This is what I put into my code to replace the old one:
rsDisplayAll.Source = "SELECT uapID, SALESCONSULTANT, INSTALLER FROM dbo.v_SalesDefault WHERE uapID = " + Replace(rsDisplayAll__MMCo
Thanks
To call a stored procedure you would set up a command object with the command type of adCmdStoredProc... http://devguru.com/Technologies/ado/quickref/command_commandtype.html
Set CommandText to the name of the sp...
Then add the parameters...
http://devguru.com/Technologies/ado/quickref/command_createparameter.html
and execute it...
http://devguru.com/Technologies/ado/quickref/command_execute.html
Set CommandText to the name of the sp...
Then add the parameters...
http://devguru.com/Technologies/ado/quickref/command_createparameter.html
and execute it...
http://devguru.com/Technologies/ado/quickref/command_execute.html
Ok, I see what you're after.
Change your v_SalesDefault to
--************************ *
CREATE VIEW dbo.v_SalesDefault
AS
SELECT
UF.*, -- this is the line that has changed
rtrim(ltrim( RepFirstName))+' '+ rtrim(ltrim( RepSurname)) AS SALESCONSULTANT,
rtrim(ltrim( RepFirstName))+' '+ rtrim(ltrim( RepSurname)) AS INSTALLER
FROM
[UAP].[dbo].[uapForm] UF,
[UAP].[dbo].[uapRepArea] URA,
[UAP].[dbo].[uapReps] UR
WHERE
SUBSTRING([PostCode],1,2) = URA.RepPostCode
and URA.RepID = UR.repID
GO
--************************ *
This will provide all columns in the uapForm (UF) table followed by the SALESCONSULTANT and INSTALLER fields.
Then change the rsDisplayAll.Source in your code to be
rsDisplayAll.Source = "SELECT * FROM dbo.v_SalesDefault WHERE uapID = " + Replace(rsDisplayAll__MMCo lParam, "'", "''") + ""
Hope this helps,
lgawlik
Change your v_SalesDefault to
--************************
CREATE VIEW dbo.v_SalesDefault
AS
SELECT
UF.*, -- this is the line that has changed
rtrim(ltrim( RepFirstName))+' '+ rtrim(ltrim( RepSurname)) AS SALESCONSULTANT,
rtrim(ltrim( RepFirstName))+' '+ rtrim(ltrim( RepSurname)) AS INSTALLER
FROM
[UAP].[dbo].[uapForm] UF,
[UAP].[dbo].[uapRepArea] URA,
[UAP].[dbo].[uapReps] UR
WHERE
SUBSTRING([PostCode],1,2) = URA.RepPostCode
and URA.RepID = UR.repID
GO
--************************
This will provide all columns in the uapForm (UF) table followed by the SALESCONSULTANT and INSTALLER fields.
Then change the rsDisplayAll.Source in your code to be
rsDisplayAll.Source = "SELECT * FROM dbo.v_SalesDefault WHERE uapID = " + Replace(rsDisplayAll__MMCo
Hope this helps,
lgawlik
Miles,
How is that last suggestion working, or not working?
Let me know if you need any further assistance.
lgawlik
How is that last suggestion working, or not working?
Let me know if you need any further assistance.
lgawlik
ASKER
Hi Lgawlik
I've been in meetings most of today so I'll try it again tomorrow. I tried it quickly and had a few problems but I want to test it again properly.
cheers for now
Miles
I've been in meetings most of today so I'll try it again tomorrow. I tried it quickly and had a few problems but I want to test it again properly.
cheers for now
Miles
ASKER
Right, I'm back.
Unfortunately the new view code you gave me didn't work - something to do with columns clashing.
Rather than concentrating on the view itself - i.e. keep with the original view. How would you go about calling the view?
In another forum someone suggested this:
<%
if (IsNull(rsDisplayAll.Field s.Item("Sa lesConsult ant").Valu e) = True) then
response.write(rsDisplayAl l2.Item("s alesconsul tant").val ue)
else
end if
%>
So if there is no salesman in the field call a second recordset and get it to call the view. don't know yet if that will work.
Miles
Unfortunately the new view code you gave me didn't work - something to do with columns clashing.
Rather than concentrating on the view itself - i.e. keep with the original view. How would you go about calling the view?
In another forum someone suggested this:
<%
if (IsNull(rsDisplayAll.Field
response.write(rsDisplayAl
else
end if
%>
So if there is no salesman in the field call a second recordset and get it to call the view. don't know yet if that will work.
Miles
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Lgawlik
I tried your method and with a few modifications got it to work.
I also found a far easier method which one of the dba's suggested.
He suggested creating two triggers on the table so that every time the postcode is entered a trigger automatically enters in the sales consultant and/or installer into their respective fields in the uapForm.
The triggers are:
-------------------------- ------
UpdateInstaller
-------------------------- ------
CREATE Trigger [UpdateInstaller]
On [dbo].[uapForm]
For Insert, Update
As
If Update (PostCode)
Begin
Update uapForm Set Installer =
(
Select rtrim(ltrim(RepFirstName)) +' '+ rtrim(ltrim(RepSurname))
From uapReps, uapRepArea
Where uapRepArea.RepPostCode = Substring([PostCode],1,2)
And uapReps.RepID = uapRepArea.RepID
)
Where Installer = ''
End
------------------------
UpdateSalesConsultant
------------------------
CREATE Trigger [UpdateSalesConsultant]
On [dbo].[uapForm]
For Insert, Update
As
If Update (PostCode)
Begin
Update uapForm Set SalesConsultant =
(
Select rtrim(ltrim(RepFirstName)) +' '+ rtrim(ltrim(RepSurname))
From uapReps, uapRepArea
Where uapRepArea.RepPostCode = Substring([PostCode],1,2)
And uapReps.RepID = uapRepArea.RepID
)
Where SalesConsultant = ''
End
Many thanks for your time and patience. I hope this example helps others.
Cheers
Miles
I tried your method and with a few modifications got it to work.
I also found a far easier method which one of the dba's suggested.
He suggested creating two triggers on the table so that every time the postcode is entered a trigger automatically enters in the sales consultant and/or installer into their respective fields in the uapForm.
The triggers are:
--------------------------
UpdateInstaller
--------------------------
CREATE Trigger [UpdateInstaller]
On [dbo].[uapForm]
For Insert, Update
As
If Update (PostCode)
Begin
Update uapForm Set Installer =
(
Select rtrim(ltrim(RepFirstName))
From uapReps, uapRepArea
Where uapRepArea.RepPostCode = Substring([PostCode],1,2)
And uapReps.RepID = uapRepArea.RepID
)
Where Installer = ''
End
------------------------
UpdateSalesConsultant
------------------------
CREATE Trigger [UpdateSalesConsultant]
On [dbo].[uapForm]
For Insert, Update
As
If Update (PostCode)
Begin
Update uapForm Set SalesConsultant =
(
Select rtrim(ltrim(RepFirstName))
From uapReps, uapRepArea
Where uapRepArea.RepPostCode = Substring([PostCode],1,2)
And uapReps.RepID = uapRepArea.RepID
)
Where SalesConsultant = ''
End
Many thanks for your time and patience. I hope this example helps others.
Cheers
Miles
It appears what you would really want is a SQL View. Something along the lines of
CREATE VIEW dbo.v_SalesDefault
AS
SELECT
[uapID],
rtrim(ltrim( RepFirstName))+' '+ rtrim(ltrim( RepSurname)) AS SALESCONSULTANT,
rtrim(ltrim( RepFirstName))+' '+ rtrim(ltrim( RepSurname)) AS INSTALLER
FROM
[UAP].[dbo].[uapForm] UF,
[UAP].[dbo].[uapRepArea] URA,
[UAP].[dbo].[uapReps] UR
WHERE
SUBSTRING([PostCode],1,2) = URA.RepPostCode
and URA.RepID = UR.repID
GO
Now, you can treat your view the same way you treat a table. In your ASP code you'd simply create the database connection and query the database for something like,
rsDisplayAll.Source = "SELECT uapID, SALESCONSULTANT, INSTALLER FROM dbo.v_SalesDefault WHERE uapID = " + Replace(rsDisplayAll__MMCo
After your recordset is returned simply refer to the columns as
rsDisplayAll.Fields.Item("
rsDisplayAll.Fields.Item("
rsDisplayAll.Fields.Item("
;just as you've done in the code above.
Hope this helps
Lgawlik