aguldber
asked on
Parameterized Query using ASP
I am creating a form that can be used to calculate shipping costs, depending on location, weight, and shipping method. My problem is how to create the parameterized queries to get the data I need from the SQL server database. My current formresults.asp page (listed below) display's the following error when run:
Microsoft VBScript runtime error '800a01a8'
Object required: 'DataCommand1.Fields(...). Value'
/ppad/formresults.asp, line 34
Any ideas on how to get this working ??? Thanks in advance...
Here's the formresults.asp code:
<%@ Language=VBScript%>
<%dim str_from_state, str_to_state, str_shipping_method, tmp_weight, str_weight, str_UOM
str_from_state = request.Form("select_from_ state")
str_to_state = request.Form("select_to_st ate")
str_shipping_method = request.Form("select_shipp ing_method ")
tmp_weight = request.Form("select_weigh t")
str_weight = CInt(tmp_weight)
str_UOM = Request.Form("select_UOM")
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<p>Shipment details</p>
<BR>
<p>shipping from: <%=str_from_state%><br>
shipping to: <%=str_to_state%><br>
using shipping method: <%=str_shipping_method%><b r>
with shipping weight: <%=str_weight%> <%=str _UOM%><br> </p>
what type is shipping weight : <%=typename(str_weight)%>
<%
Set PPAD = Server.CreateObject("ADODB .Connectio n")
PPAD.ConnectionTimeout = Session("PPAD_ConnectionTi meout")
PPAD.CommandTimeout = Session("PPAD_CommandTimeo ut")
PPAD.Open Session("PPAD_ConnectionSt ring"), Session("PPAD_RuntimeUserN ame"), Session("PPAD_RuntimePassw ord")
Set cmdTemp = Server.CreateObject("ADODB .Command")
Set DataCommand1 = Server.CreateObject("ADODB .Recordset ")
cmdTemp.CommandText = "SELECT MIN(minimum_weight), MAX(maximum_weight) FROM dbo.LTL_rate WHERE from_state = '" & str_from_state & "' AND to_state = '" & str_to_state & "' AND unit_of_measure = '" & str_UOM & "';"
cmdTemp.CommandType = 1
Set cmdTemp.ActiveConnection = PPAD
DataCommand1.Open cmdTemp, , 0, 1
DataCommand1.MoveFirst
set abs_min_weight = DataCommand1.Fields(0).Val ue
set abs_max_weight = DataCommand1.Fields(1).val ue
DataCommand1.close
%>
the minimum value = <%=abs_min_weight%>
the maximum value = <%=abs_max_weight%>
<P> </P>
</BODY>
</HTML>
Microsoft VBScript runtime error '800a01a8'
Object required: 'DataCommand1.Fields(...).
/ppad/formresults.asp, line 34
Any ideas on how to get this working ??? Thanks in advance...
Here's the formresults.asp code:
<%@ Language=VBScript%>
<%dim str_from_state, str_to_state, str_shipping_method, tmp_weight, str_weight, str_UOM
str_from_state = request.Form("select_from_
str_to_state = request.Form("select_to_st
str_shipping_method = request.Form("select_shipp
tmp_weight = request.Form("select_weigh
str_weight = CInt(tmp_weight)
str_UOM = Request.Form("select_UOM")
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<p>Shipment details</p>
<BR>
<p>shipping from: <%=str_from_state%><br>
shipping to: <%=str_to_state%><br>
using shipping method: <%=str_shipping_method%><b
with shipping weight: <%=str_weight%> <%=str
what type is shipping weight : <%=typename(str_weight)%>
<%
Set PPAD = Server.CreateObject("ADODB
PPAD.ConnectionTimeout = Session("PPAD_ConnectionTi
PPAD.CommandTimeout = Session("PPAD_CommandTimeo
PPAD.Open Session("PPAD_ConnectionSt
Set cmdTemp = Server.CreateObject("ADODB
Set DataCommand1 = Server.CreateObject("ADODB
cmdTemp.CommandText = "SELECT MIN(minimum_weight), MAX(maximum_weight) FROM dbo.LTL_rate WHERE from_state = '" & str_from_state & "' AND to_state = '" & str_to_state & "' AND unit_of_measure = '" & str_UOM & "';"
cmdTemp.CommandType = 1
Set cmdTemp.ActiveConnection = PPAD
DataCommand1.Open cmdTemp, , 0, 1
DataCommand1.MoveFirst
set abs_min_weight = DataCommand1.Fields(0).Val
set abs_max_weight = DataCommand1.Fields(1).val
DataCommand1.close
%>
the minimum value = <%=abs_min_weight%>
the maximum value = <%=abs_max_weight%>
<P> </P>
</BODY>
</HTML>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.