?
Solved

Recordset Error WHERE IDNmbr = " & SurveyID

Posted on 2006-05-30
14
Medium Priority
?
147 Views
Last Modified: 2010-04-25
First web page saves the data to the table LOTADATA, just fine.
I pass SurveyID from first to second page.
I want to use that ID to show the field Score on the second web page, but get an error using this code.
**THANK you for any help**JOHN

SurveyID = Request("SurveyID")

<%
Dim LOTADATA
Dim LOTADATA_numRows

Set LOTADATA = Server.CreateObject("ADODB.Recordset")
LOTADATA.ActiveConnection = MM_ConnectOpt_STRING
LOTADATA.Source = "SELECT Score  FROM LOTADATA  WHERE IDNmbr = " & SurveyID
LOTADATA.CursorType = 0
LOTADATA.CursorLocation = 2
LOTADATA.LockType = 1
LOTADATA.Open()

LOTADATA_numRows = 0
%>

<p align="center">Your score was <%=(LOTADATA.Fields.Item("Score").Value)%>.</p>
0
Comment
Question by:obernai
  • 6
  • 5
11 Comments
 
LVL 30

Expert Comment

by:Irwin Santos
ID: 16794774
"SELECT Score  FROM LOTADATA  WHERE IDNmbr = " & SurveyID

-----------------------
use this
-----------------------
SELECT Score, IDNmbr FROM LOTADATA WHERE IDNmbr = '" & SurveyID & "'"
0
 
LVL 30

Expert Comment

by:Irwin Santos
ID: 16794791
Add these 2 items to your code at the very beginning...(1st & 2nd line)

<% @ LANGUAGE = VBSCRIPT%>
<% Option Explicit %>

Then in Internet Explorer, go to TOOLS-INTERNET OPTIONS - ADVANCE tab, then locate "SHOW FRIENDLY HTTP ERROR MESSAGES", UNCHECK that box.

Post back any errors (exact errors)
0
 

Author Comment

by:obernai
ID: 16795067
Here is the error I am getting:

Microsoft VBScript runtime error '800a01f4'

Variable is undefined: 'SurveyID'

/lot_finish.asp, line 10
0
Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

 

Author Comment

by:obernai
ID: 16795152
I changed the code to this:

<%@LANGUAGE="VBSCRIPT"%>
<% Option Explicit %>
<!--#include file="Connections/ConnectOpt.asp" -->

<%
Dim LOTADATA
Dim LOTADATA_numRows
Dim SurveyID
SurveyID = Request("SurveyID")
Set LOTADATA = Server.CreateObject("ADODB.Recordset")
LOTADATA.ActiveConnection = MM_ConnectOpt_STRING
LOTADATA.Source = "SELECT Score, IDNmbr FROM LOTADATA  WHERE IDNmbr = '" & SurveyID & "'"
LOTADATA.CursorType = 0
LOTADATA.CursorLocation = 2
LOTADATA.LockType = 1
LOTADATA.Open()

LOTADATA_numRows = 0

Here is the error I get now:

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'

[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.

/lot_finish.asp, line 18
0
 
LVL 30

Expert Comment

by:Irwin Santos
ID: 16795379
ok.. what is the datatype for IDNmbr?

also

SurveyID=Request("SurveyID") is NOT correct in syntax.. if you are calling from a form, thenuse

Request.Form("SurveyID"), if from a hyperlink

Request.Query("SurveyID")

0
 

Author Comment

by:obernai
ID: 16795577
IDNmbr is Numeric
0
 
LVL 30

Expert Comment

by:Irwin Santos
ID: 16795617
did you apply my recent comment?
0
 

Author Comment

by:obernai
ID: 16795942
Yes, no difference.
0
 
LVL 30

Expert Comment

by:Irwin Santos
ID: 16795953
what does your code look like now?


instead of
SurveyID = Request("SurveyID")

put

SurveyID = 1

(or some other valid value in your table)
0
 

Author Comment

by:obernai
ID: 16797409
The value of SurveyID is a numeric value.

The code
SurveyID = Request("SurveyID")
is just calling for the value from the previous form page so that all the records in the DB tables are linkable via the IDNmbr table field.

I have a table called IDCreator where it has one numeric field that is increased by one after each user completes the first page of the survey.  This number is passed to each page (as 'SurveyID' and entered into each table as IDNmbr).


So on the previous page, the code for this process is this:

    If (MM_editRedirectUrl <> "") Then
       If (MM_editRedirectUrl <> "") Then
      MM_editRedirectUrl = MM_editRedirectUrl & "?SurveyID="& SurveyID &"" 
                         'the ID is passed to Next Page as query string
      Response.Redirect(MM_editRedirectUrl)
    End If

I have been using this method for several years without a problem.  So I can have multiple users completing the survey at the same time.

I have never tried to load a field specific to the user's IDNmbr though....
0
 
LVL 30

Accepted Solution

by:
Irwin Santos earned 2000 total points
ID: 16797480
"SurveyID = Request("SurveyID")"  <<<<<<<<<<<<<<<<<< SYNTAX IS NOT CORRECT!!!!!  >>>>>>>>>>>>>>>>>>>>>

SurveyID = Request.QueryString("SurveyID")

The error "[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression. "

Tells me so.  that you want to put a value in your query...however due to the incorrect syntax and subsequent value in SurveyID...that cannot be done.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

I still run into .cgi files every now and then. In some instances, I actually prefer the simplicity of a .cgi script to other options. Since I use DreamWeaver extensively, what I needed was a way to open .cgi scripts in Dreamweaver. And I wanted to …
Adobe Dreamweaver CS5 is a WYSIWYG web page editor that has advanced HTML, CSS, and Javascript rendering functionality and is probably the most well-known HTML editor available. Much of Dreamweaver's appeal centers around the Design View interfac…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

807 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