By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,825 Members | 1,232 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,825 IT Pros & Developers. It's quick & easy.

Creating Queries does not give any result

P: n/a
BP
I get the following error: Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: ''
/myweb4/authorised_user_page.asp, line 70
and line 70 of my code is: <% rsCheckUser1.Open strSQL1,
strcon1 %>

Here is the full code:
%
dim adocon1
dim strcon1
Dim rsCheckUser1 'Database Recordset variable
Dim strAccessDB1 'Holds the Access Database Name
dim strSQL1 'Database query String
Dim strUserName 'Holds the name of the user

'Check the database to see if user exsits and read in
there password
'Initialise the strAccessDB variable with the name of the
Access Database
strAccessDB1 = "users"

'Create a connection odject

set adocon1 = Server.CreateObject("ADODB.Connection")

'Database connection info and driver
strcon1 = "DRIVER={Microsoft Access Driver
(*.mdb)};uid=;pwd=letmein; DBQ=" & Server.MapPath
(strAccessDB1)

'Set an active connection to the Connection object
adocon1.open strcon1

'Create a recordset object
set rsCheckUser1 = Server.CreateObject("ADODB.Recordset")

'If the session variable is False or does not exsist then
redirect the user to the unauthorised user page
If Session("blnIsUserGood") = False or IsNull(Session
("blnIsUserGood")) = True then
'Redirect to unathorised user page
Response.Redirect"unauthorised_user_page.htm"
End If
%>

<html>
<head>
<title>Authorised User</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">

'Get the users name passed from the previous page
<% strUserName = Request.QueryString("name") %>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<!--
<table width="518" border="0" cellspacing="0"
cellpadding="0" align="center">
<tr>
<td align="center">
<h1>Authorised Access</h1>
</td>
</tr>
</table>
<div align="center">
<p><br>
Welcome <b>
<% =strUserName %>
</b> to the password proteceted area of the web site.
</p>
<p>&nbsp;</p>
-->

<%

strSQL1 = "select tblresults.userid,
tblresults.date, tblresults.bf, tblresults.proteins,
tblresults.othersolids from tblresults where
tblresults.userid='" & strusername & "'" %>

'Query the database
<% rsCheckUser1.Open strSQL1, strcon1 %>
<p>&nbsp;
<table>
<%do while not rscheckuser1.eof%>
<tr><td><%response.write rscheckuser1
("UserID") %></td></tr>
<tr><td><%response.write rscheckuser1
("Date") %></td></tr>
<tr><td><%response.write rscheckuser1
("BF") %></td></tr>
<tr><td><%response.write rscheckuser1
("Proteins") %></td></tr>
<tr><td><%response.write rscheckuser1
("OtherSolids") %></td></tr>
<tr><td><hr></td></tr>
<%
rscheckuser1.movenext
loop
%>
</table>
</p>
</div>

</body>
</html>
The only thing I am doing is bringing in the username
value from the previous page and using that value to find
all the records and display them on the current web
page. I do not see what is wrong with my code. If
anyone could please help.
Jul 19 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Are you sure that's the line with the error?
Are you using Option Explicit?

Why don't you just do:

Set rsCheckUser1 = adocon1 .Execute(strSQL)

Ray at work

"BP" <bs*****@hotmail.com> wrote in message
news:27*****************************@phx.gbl...
I get the following error: Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: ''
/myweb4/authorised_user_page.asp, line 70
and line 70 of my code is: <% rsCheckUser1.Open strSQL1,
strcon1 %>

Here is the full code:


[trimmed the nonsense]
Jul 19 '05 #2

P: n/a
See responses inline:
BP wrote:
I get the following error: Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: ''
/myweb4/authorised_user_page.asp, line 70
and line 70 of my code is: <% rsCheckUser1.Open strSQL1,
strcon1 %>

Here is the full code:
% <snip> 'Create a connection odject

set adocon1 = Server.CreateObject("ADODB.Connection")

'Database connection info and driver
strcon1 = "DRIVER={Microsoft Access Driver
(*.mdb)};uid=;pwd=letmein; DBQ=" & Server.MapPath
(strAccessDB1)
It's got nothing to do with your problem but don't use ODBC. It's been
deprecated by MS. Use the native Jet OLEDB provider instead. See
www.connectionstrings.com for an example.
'Set an active connection to the Connection object
adocon1.open strcon1

'Create a recordset object
set rsCheckUser1 = Server.CreateObject("ADODB.Recordset")
<snip of totally irrelevant stuff> strSQL1 = "select tblresults.userid,
tblresults.date, tblresults.bf, tblresults.proteins,
tblresults.othersolids from tblresults where
tblresults.userid='" & strusername & "'" %>
Use Response.Write here to make sure your strSQL1 variable contains what you
think it contains:
Response.Write strSQL1 & "<BR>"

'Query the database
<% rsCheckUser1.Open strSQL1, strcon1 %>
Nooo! Why create and open a connection if you're not going to use it? Also,
you should tell ADO what the command type is instead of making it guess:
<%
const adCmdText = 1
rsCheckUser1.Open strSQL1, adocon1,,,adCmdText
%>

<snip of more irrelevant stuff>
The only thing I am doing is bringing in the username
value from the previous page and using that value to find
all the records and display them on the current web
page. I do not see what is wrong with my code. If
anyone could please help.


I don't see anything that would cause an "Object Required" error. Are you
using Option Explicit? If not, you should because it will help you avoid
mistakes in typing your variables. I suggest you create a new page that
contains the bare minimum code to attempt to reproduce the error, something
like this:

<%
Option Explicit
const adCmdText = 1
dim adocon1
dim strcon1
Dim rsCheckUser1 'Database Recordset variable
Dim strAccessDB1 'Holds the Access Database Name
dim strSQL1 'Database query String
Dim strUserName 'Holds the name of the user
strAccessDB1 = "users"
set adocon1 = Server.CreateObject("ADODB.Connection")
strcon1="provider=microsoft.jet.oledb.4.0;" _ &
"data source=" & Server.MapPath(strAccessDB1)
strSQL1 = "select tblresults.userid," & _
tblresults.date, tblresults.bf, tblresults.proteins," & _
tblresults.othersolids from tblresults where ," & _
tblresults.userid='" & strusername & "'" %>
Response.Write strSQL1 & "<BR>"
set rsCheckUser1 = Server.CreateObject("ADODB.Recordset")
rsCheckUser1.Open strSQL1, adocon1,,,adCmdText
if not rsCheckUser1.eof then
response.write rsCheckUser1.GetString(,,"; ","<BR>")
else
response.write "No Records were returned
end if
rsCheckUser1.close: set rsCheckUser1=nothing
adocon1.close: set adocon1 = nothing
%>

HTH,
Bob Barrows
Jul 19 '05 #3

P: n/a
should be:

<% rsCheckUser1.Open strSQL1, adocon1 %>

the second parameter must be the connection object, not the connection
string !

"BP" <bs*****@hotmail.com> wrote in message
news:27*****************************@phx.gbl...
I get the following error: Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: ''
/myweb4/authorised_user_page.asp, line 70
and line 70 of my code is: <% rsCheckUser1.Open strSQL1,
strcon1 %>

Here is the full code:
%
dim adocon1
dim strcon1
Dim rsCheckUser1 'Database Recordset variable
Dim strAccessDB1 'Holds the Access Database Name
dim strSQL1 'Database query String
Dim strUserName 'Holds the name of the user

'Check the database to see if user exsits and read in
there password
'Initialise the strAccessDB variable with the name of the
Access Database
strAccessDB1 = "users"

'Create a connection odject

set adocon1 = Server.CreateObject("ADODB.Connection")

'Database connection info and driver
strcon1 = "DRIVER={Microsoft Access Driver
(*.mdb)};uid=;pwd=letmein; DBQ=" & Server.MapPath
(strAccessDB1)

'Set an active connection to the Connection object
adocon1.open strcon1

'Create a recordset object
set rsCheckUser1 = Server.CreateObject("ADODB.Recordset")

'If the session variable is False or does not exsist then
redirect the user to the unauthorised user page
If Session("blnIsUserGood") = False or IsNull(Session
("blnIsUserGood")) = True then
'Redirect to unathorised user page
Response.Redirect"unauthorised_user_page.htm"
End If
%>

<html>
<head>
<title>Authorised User</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">

'Get the users name passed from the previous page
<% strUserName = Request.QueryString("name") %>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<!--
<table width="518" border="0" cellspacing="0"
cellpadding="0" align="center">
<tr>
<td align="center">
<h1>Authorised Access</h1>
</td>
</tr>
</table>
<div align="center">
<p><br>
Welcome <b>
<% =strUserName %>
</b> to the password proteceted area of the web site.
</p>
<p>&nbsp;</p>
-->

<%

strSQL1 = "select tblresults.userid,
tblresults.date, tblresults.bf, tblresults.proteins,
tblresults.othersolids from tblresults where
tblresults.userid='" & strusername & "'" %>

'Query the database
<% rsCheckUser1.Open strSQL1, strcon1 %>
<p>&nbsp;
<table>
<%do while not rscheckuser1.eof%>
<tr><td><%response.write rscheckuser1
("UserID") %></td></tr>
<tr><td><%response.write rscheckuser1
("Date") %></td></tr>
<tr><td><%response.write rscheckuser1
("BF") %></td></tr>
<tr><td><%response.write rscheckuser1
("Proteins") %></td></tr>
<tr><td><%response.write rscheckuser1
("OtherSolids") %></td></tr>
<tr><td><hr></td></tr>
<%
rscheckuser1.movenext
loop
%>
</table>
</p>
</div>

</body>
</html>
The only thing I am doing is bringing in the username
value from the previous page and using that value to find
all the records and display them on the current web
page. I do not see what is wrong with my code. If
anyone could please help.

Jul 19 '05 #4

P: n/a
Slight correction:
<%
Option Explicit
const adCmdText = 1
dim adocon1
dim strcon1
Dim rsCheckUser1 'Database Recordset variable
Dim strAccessDB1 'Holds the Access Database Name
dim strSQL1 'Database query String
Dim strUserName 'Holds the name of the user
strAccessDB1 = "users"
'>>>>correction follows
strUserName = Request.QueryString("name")
'>>>>end correction
set adocon1 = Server.CreateObject("ADODB.Connection")
strcon1="provider=microsoft.jet.oledb.4.0;" _ &
"data source=" & Server.MapPath(strAccessDB1)
strSQL1 = "select tblresults.userid," & _
tblresults.date, tblresults.bf, tblresults.proteins," & _
tblresults.othersolids from tblresults where ," & _
tblresults.userid='" & strusername & "'" %>
Response.Write strSQL1 & "<BR>"
set rsCheckUser1 = Server.CreateObject("ADODB.Recordset")
rsCheckUser1.Open strSQL1, adocon1,,,adCmdText
if not rsCheckUser1.eof then
response.write rsCheckUser1.GetString(,,"; ","<BR>")
else
response.write "No Records were returned
end if
rsCheckUser1.close: set rsCheckUser1=nothing
adocon1.close: set adocon1 = nothing
%>

HTH,
Bob Barrows

Jul 19 '05 #5

P: n/a
String will work, but it sure defeats the purpose of creating that first
connection.

Ray at home

"Mike Florio" <mi**@micro-point.com> wrote in message
news:vo************@corp.supernews.com...
should be:

<% rsCheckUser1.Open strSQL1, adocon1 %>

the second parameter must be the connection object, not the connection
string !

Jul 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.