Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Interesting Recordset error...

Status
Not open for further replies.

disk42

Programmer
Nov 14, 2003
16
0
0
US
Hello all,

I just installed MySQL on Windows 2000 Server, and am trying to rewrite my ASPs to interface with it. When I try to access one of the columns in the recordset, Microsoft Script Debugging pops up with an "Exception Occurred" error. In the command window I type in, and receive back, the following:

? objrs("FilePath")
[error]

? objrs("ImageType")
Reg

? objrs("FilePath")
G:/Documents and Settings/disk42/Desktop/analog.txt

ImageType happens to be the column right before FilePath. I can't think of any reason why I can't access FilePath until after I've accessed ImageType. Anyone else run into this problem, or know what may cause it?

Thanks for any help,
Phil
 
post your ASP code.

Bye

Qatqat

Life is what happens when you are making other plans.
 
I've bolded the offending line:

<%@ Language=VBScript %>
<%Response.Buffer = True%>
<!-- #include file="SecurityHDR.asp" -->

<%
'****************************************
'* OrderForm.asp
'*
'* -initializes the order process
'* -retrieves stored order data from the database
'* -starts up and passes data to the order form applet
'****************************************

'If user doesn't have an order number, send them back to get one (workaround for problems caused by user hitting "Back" button)
if Session("OrderNumber") = "" then
Response.Redirect "PixChoice.asp"
end if

'Acquire passed/stored values
strUserName = Session("UserName")
intOrderNum = Session("OrderNumber")
strFileType = Request.QueryString("FileType")
%>
<!--#include file="../Secure/dbconn.asp" -->
<%
Set objrs = Server.CreateObject("ADODB.Recordset")
Set objrsPI = Server.CreateObject("ADODB.Recordset")

'Retrieve user information from database
strSQLPI = "SELECT * FROM Users WHERE UserName ='" & strUserName & "'"
objrsPI.Open strSQLPI,objcon

'Retrieve stored order data from the database
strSQL = "SELECT * FROM Orders WHERE OrderNumber=" & intOrderNum & " AND ImageType NOT IN ('Placeholder') ORDER BY FileName,Quantity ASC"
objrs.open strSQL, objcon
%>
<HTML>
<HEAD>
<TITLE>Order Form for Order #<% =intOrderNum %></TITLE>
</HEAD>
<BODY>
<APPLET CODE="OrderForm" ARCHIVE="sOrderForm.jar" NAME="OrderForm" BGCOLOR="#FFFFFF" WIDTH=100% HEIGHT=100%>
<PARAM NAME="FileType" VALUE="<% =strFileType %>">
<PARAM NAME="OrderNumber" VALUE="<% =intOrderNum %>">
<PARAM NAME="FName" VALUE="<% =objrsPI("FName") %>">
<PARAM NAME="LName" VALUE="<% =objrsPI("LName") %>">
<PARAM NAME="UserName" VALUE="<% =strUserName %>">
<%
'Assign stored order data to parameters for applet to retrieve data from
fileCount = 0
pkgCount = 0
strPkgCount = ""

'If there is stored order data...
if not (objrs.bof and objrs.eof) then
ct = -1
cn = 0
strOldFile = ""
%><PARAM NAME="Rush" VALUE="<% =objrs("Rush") %>">
<PARAM NAME="Ship" VALUE="<% =objrs("Ship") %>">
<PARAM NAME="Reference" VALUE="<% =objrs("Reference") %>">
<%
'Do this until we reach the end of the order data
while not objrs.eof
'If there is a file name associated with this package...
if objrs("FilePath") <> "" then
'Is this package associated with the same file as the last package? If not, then...
if strOldFile <> objrs("FilePath") then
'Increment file counter
ct = ct + 1
%>

<PARAM NAME="FileName<% =ct %>" VALUE="<% =Replace(objrs("FilePath"),"/","\") %>">
<%
'Reset package counter
cn = 0
'Increment total file count
fileCount = fileCount + 1
'Reset total package count (for this file)
pkgCount = 0
'Add to comma-delimited package count string
strPkgCount = strPkgCount & ","
end if

'If a quantity (package) was entered for this file...
if objrs("Quantity") <> "" then
'Increment total package count (for this file)...
pkgCount = pkgCount + 1

'...and add it to the end of the comma-delimited package count string
strPkgCount = Left(strPkgCount, instrrev(strPkgCount, ",")) & pkgCount

'Now, assign package data to parameters
%><PARAM NAME="Quantity<% =ct %>_<% =cn %>" VALUE="<% =objrs("Quantity") %>">
<PARAM NAME="Size<% =ct %>_<% =cn %>" VALUE="<% =objrs("Size") %>">
<PARAM NAME="Mount<% =ct %>_<% =cn %>" VALUE="<% =objrs("Mount") %>">
<PARAM NAME="Texture<% =ct %>_<% =cn %>" VALUE="<% =objrs("Texture") %>">
<PARAM NAME="Spray<% =ct %>_<% =cn %>" VALUE="<% =objrs("Spray") %>">
<PARAM NAME="Spot<% =ct %>_<% =cn %>" VALUE="<% =objrs("Spot") %>">
<PARAM NAME="UC<% =ct %>_<% =cn %>" VALUE="<% =objrs("UC") %>">
<PARAM NAME="DA<% =ct %>_<% =cn %>" VALUE="<% =objrs("DA") %>">
<PARAM NAME="DAtext<% =ct %>_<% =cn %>" VALUE="<% =objrs("DAtext") %>">
<PARAM NAME="GC<% =ct %>_<% =cn %>" VALUE="<% =objrs("GC") %>">
<PARAM NAME="GCtext<% =ct %>_<% =cn %>" VALUE="<% =objrs("GCtext") %>">
<PARAM NAME="SpecInstr<% =ct %>_<% =cn %>" VALUE="<% =objrs("Instructions") %>">
<%
'Increment package counter
cn = cn + 1
else
'No quantity (package) entered for this file, so add a "0" to the comma-delimited package count string
strPkgCount = Left(strPkgCount, instrrev(strPkgCount, ",")+1) & "0"
end if
'Save this file name, in case the next package is associated with the same file
strOldFile = Replace(objrs("FilePath"),"/","\")
'Move to the next package
objrs.MoveNext
end if
wend

'Assign comma-delimited package count string to a parameter
%>
<PARAM NAME="PackageCount" VALUE="<% =Right(strPkgCount, len(strPkgCount)-1) %>">
<%
end if

'Assign total file count to a parameter
%>
<PARAM NAME="FileCount" VALUE="<% =fileCount %>">
<!-- This text will be displayed if the customer does not have a Java plug-in at all -->
You need to have at least version 1.4.1 of the Java plug-in, which can be obtained at <A HREF="</APPLET>
</BODY>
</HTML>
 
Figured it out:

Apparently, you can only access a column in a particular row ONCE, then MySQL doesn't like it anymore. So, I assigned the columns to variables and just used those, rather than call, for instance, objrs("FilePath") more than once.

Thanks anyway :)

Phil
 
What are the column types of the columns your code references, and in what order?

I remember a problem with Microsoft's ODBC subsystem, where you could only reference text fields in the order in which they appeared in the returned recordset.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Yeah, that's what it seemed like at first.
Here's the DB structure:
OrderNumber mediumint(9)
ImageType tinytext
FileName text
FilePath text
Quantity tinytext
Size tinytext
Mount tinytext
Texture tinytext
Spray tinytext
Spot tinytext
UC tinytext
DA tinytext
DAtext text
GC tinytext
GCtext text
Instructions text
Rush tinytext
Ship text
Reference text
UserName tinytext
PostDate datetime
ETADate datetime
Uploaded tinyint(1)
Printed tinyint(1)
Completed tinyint(1)
PickedUp tinyint(1)

Another problem I'm having (though I've worked around it, I'd rather not use the workaround) is that I can't reference a field that has nothing in it, i.e.:

If I run an INSERT:
INSERT INTO Orders(OrderNumber, ImageType, Size, Mount) VALUES(900000, "Reg", "4x6", "")

then try to access Mount:
objrs("Mount")

I get an error (Multi-step OLE DB something....). I got around it by putting "None" into Mount, but I'm wondering if there's a way to not have to put anything into the column.

*shrug* Oh well....thanks :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top