p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

  Return to Index  

proasp_codeclinic thread: using more than one recordset for a connection object

Message #1 by "feroz khan" <feroz_77_city@h...> on Wed, 6 Mar 2002 17:55:57
This is a multi-part message in MIME format.

Content-Type: text/plain;
Content-Transfer-Encoding: 7bit

David, at a glance I don't see a problem with the code you've provided.
First thing to check is the spelling of your field names... misspelling
them is the most common cause of the "Too few parameters" error.
The remaining suggestions won't by themselves fix your problem, but your
code suggests structural problems which may, somewhere else, be leading
to confusion that's causing your current error.
- why do you have a different table for each user type?  Surely users
share common characteristics (like a login ID, a password, perhaps
others).  Maybe you could think about a single table Users, with a
column UserType that identifies which users are students, lecturers,
etc.  If the different user types have characteristics that are not
shared by other types, then a separate table is used to store those.
For example, a separate Students table might contain data specific only
to students, and include a UserID column as the the "foreign key" to
their record in the Users table so the two tables can be joined on the
- why are you creating a different recordset variable for each user
type?  From your description and code, it seems that a single recordset
variable might suffice for all user types, even if you retain your
separate tables for each user type.
- perhaps you stripped it out for simplicity of demonstrating here, but
your code shows no checking to ensure that the three values you're
retrieving from Request.Form are not empty or null, and that the value
you're retrieving using the Left() function is at least three characters
long.  There's a high potential for trouble in this area, though not
usually the "Too few parameters" error.
- think about using the Select Case / End Select structure rather than
If Elseif Elseif End If
 -----Original Message-----
From: David Cameron [mailto:dcameron@i...] 
Sent: Wednesday, March 06, 2002 10:37 PM
To: Code Clinic
Subject: [proasp_codeclinic] RE: using more than one recordset for a
conne ction object


David Cameron 

-----Original Message----- 
From: feroz khan [mailto:feroz_77_city@h...] 
Sent: Thursday, 7 March 2002 4:56 AM 
To: Code Clinic 
Subject: [proasp_codeclinic] using more than one recordset for a 
connection object 

Please could someone have a look at this which is an authentication 
script for different types of users of my website.  It is supposed to 
read the first 3 letters of their userID to direct them to the 
appropriate webpage.  It does seem to work for the very first statement 
(if strlog = "lec" then) and seems to point to the correct page but it 
doesn't work for the others.  Is there supposed to be another parameter 
that i must include to differentiate between the other recordsets?. I 
would appreciate any help, thank you. 

Error Type: 
Microsoft OLE DB Provider for ODBC Drivers (0x80040E10) 
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected
/asp/checklogin3.asp, line 71 

(script start) 

<!--METADATA TYPE="typelib" 
                FILE="C:\Program Files\Common 
Files\System\ado\msado15.dll" --> 
<% option explicit %> 
<title>checking login details</title> 


        Dim objconn, strid1, strlog, strps, rslec, rsstu, rsstf, rsmrk, 
        strid1 = Request.Form("userid") 
        strlog = Left(Request.Form("userid"),3) 
        strps = Request.Form("passwordid") 
        set objconn = server.createobject("ADODB.Connection") 
        objconn.open "dsn=feroz"        
                if strlog = "lec" then 
                        set rslec 
                        QRY = "select * from LECTURER where Lecturer_ID 
= '" & strid1 & "';" 
                        rslec.open QRY, objconn, adopenstatic, 
adlockreadonly, adcmdtext 
                                if rslec.EOF then 
                                        response.redirect "login.asp" 
                                        response.redirect "lecpage.asp" 
                                end if 

                elseif strlog = "stu" then 
                        set rsstu 
                        QRY = "select * from STUDENT where Student_ID 
= '" & strid1 & "';" 
                        rsstu.open QRY, objconn, adopenstatic, 
adlockreadonly, adcmdtext 
                                if rsstu.EOF then 
                                        response.redirect "login.asp" 
                                        response.redirect "stupage.asp" 
                                end if 

                elseif strlog = "mrk" then 
                        set rsmrk 
                        QRY = "select * from MARKS STAFF where 
Marks_staff_ID = '" & strid1 & "';" 
                        rsmrk.open QRY, objconn, adopenstatic, 
adlockreadonly, adcmdtext 
                                if rsmrk.EOF then 
                                        response.redirect "login.asp" 
                                        response.redirect "mrkpage.asp" 
                                end if 

                elseif strlog = "stf" then 
                        set rsstf 
                        QRY = "select * from TIMETABLE STAFF where 
Time_staff_ID = '" & strid1 & "';" 
                        rsstf.open QRY, objconn, adopenstatic, 
adlockreadonly, adcmdtext 
                                if rsstf.EOF then 
                                        response.redirect "login.asp" 
                                        response.redirect "stfpage.asp" 
                                end if 

                else response.redirect "login.asp" 
                end if 




  Return to Index