473,785 Members | 2,396 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating Queries does not give any result

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.Op en 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.CreateOb ject("ADODB.Con nection")

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

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

'Create a recordset object
set rsCheckUser1 = Server.CreateOb ject("ADODB.Rec ordset")

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

<html>
<head>
<title>Authoris ed 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.QuerySt ring("name") %>
</head>

<body bgcolor="#FFFFF F" text="#000000">
<!--
<table width="518" border="0" cellspacing="0"
cellpadding="0" align="center">
<tr>
<td align="center">
<h1>Authorise d 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.user id,
tblresults.date , tblresults.bf, tblresults.prot eins,
tblresults.othe rsolids from tblresults where
tblresults.user id='" & strusername & "'" %>

'Query the database
<% rsCheckUser1.Op en strSQL1, strcon1 %>
<p>&nbsp;
<table>
<%do while not rscheckuser1.eo f%>
<tr><td><%respo nse.write rscheckuser1
("UserID") %></td></tr>
<tr><td><%respo nse.write rscheckuser1
("Date") %></td></tr>
<tr><td><%respo nse.write rscheckuser1
("BF") %></td></tr>
<tr><td><%respo nse.write rscheckuser1
("Proteins") %></td></tr>
<tr><td><%respo nse.write rscheckuser1
("OtherSolid s") %></td></tr>
<tr><td><hr></td></tr>
<%
rscheckuser1.mo venext
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
5 2113
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*****@hotmai l.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.Op en strSQL1,
strcon1 %>

Here is the full code:


[trimmed the nonsense]
Jul 19 '05 #2
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.Op en strSQL1,
strcon1 %>

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

set adocon1 = Server.CreateOb ject("ADODB.Con nection")

'Database connection info and driver
strcon1 = "DRIVER={Micros oft Access Driver
(*.mdb)};uid=;p wd=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.CreateOb ject("ADODB.Rec ordset")
<snip of totally irrelevant stuff> strSQL1 = "select tblresults.user id,
tblresults.date , tblresults.bf, tblresults.prot eins,
tblresults.othe rsolids from tblresults where
tblresults.user id='" & 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.Op en 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.Op en strSQL1, adocon1,,,adCmd Text
%>

<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.CreateOb ject("ADODB.Con nection")
strcon1="provid er=microsoft.je t.oledb.4.0;" _ &
"data source=" & Server.MapPath( strAccessDB1)
strSQL1 = "select tblresults.user id," & _
tblresults.date , tblresults.bf, tblresults.prot eins," & _
tblresults.othe rsolids from tblresults where ," & _
tblresults.user id='" & strusername & "'" %>
Response.Write strSQL1 & "<BR>"
set rsCheckUser1 = Server.CreateOb ject("ADODB.Rec ordset")
rsCheckUser1.Op en strSQL1, adocon1,,,adCmd Text
if not rsCheckUser1.eo f then
response.write rsCheckUser1.Ge tString(,,"; ","<BR>")
else
response.write "No Records were returned
end if
rsCheckUser1.cl ose: set rsCheckUser1=no thing
adocon1.close: set adocon1 = nothing
%>

HTH,
Bob Barrows
Jul 19 '05 #3
should be:

<% rsCheckUser1.Op en strSQL1, adocon1 %>

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

"BP" <bs*****@hotmai l.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.Op en 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.CreateOb ject("ADODB.Con nection")

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

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

'Create a recordset object
set rsCheckUser1 = Server.CreateOb ject("ADODB.Rec ordset")

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

<html>
<head>
<title>Authoris ed 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.QuerySt ring("name") %>
</head>

<body bgcolor="#FFFFF F" text="#000000">
<!--
<table width="518" border="0" cellspacing="0"
cellpadding="0" align="center">
<tr>
<td align="center">
<h1>Authorise d 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.user id,
tblresults.date , tblresults.bf, tblresults.prot eins,
tblresults.othe rsolids from tblresults where
tblresults.user id='" & strusername & "'" %>

'Query the database
<% rsCheckUser1.Op en strSQL1, strcon1 %>
<p>&nbsp;
<table>
<%do while not rscheckuser1.eo f%>
<tr><td><%respo nse.write rscheckuser1
("UserID") %></td></tr>
<tr><td><%respo nse.write rscheckuser1
("Date") %></td></tr>
<tr><td><%respo nse.write rscheckuser1
("BF") %></td></tr>
<tr><td><%respo nse.write rscheckuser1
("Proteins") %></td></tr>
<tr><td><%respo nse.write rscheckuser1
("OtherSolid s") %></td></tr>
<tr><td><hr></td></tr>
<%
rscheckuser1.mo venext
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
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"
'>>>>correctio n follows
strUserName = Request.QuerySt ring("name")
'>>>>end correction
set adocon1 = Server.CreateOb ject("ADODB.Con nection")
strcon1="provid er=microsoft.je t.oledb.4.0;" _ &
"data source=" & Server.MapPath( strAccessDB1)
strSQL1 = "select tblresults.user id," & _
tblresults.date , tblresults.bf, tblresults.prot eins," & _
tblresults.othe rsolids from tblresults where ," & _
tblresults.user id='" & strusername & "'" %>
Response.Write strSQL1 & "<BR>"
set rsCheckUser1 = Server.CreateOb ject("ADODB.Rec ordset")
rsCheckUser1.Op en strSQL1, adocon1,,,adCmd Text
if not rsCheckUser1.eo f then
response.write rsCheckUser1.Ge tString(,,"; ","<BR>")
else
response.write "No Records were returned
end if
rsCheckUser1.cl ose: set rsCheckUser1=no thing
adocon1.close: set adocon1 = nothing
%>

HTH,
Bob Barrows

Jul 19 '05 #5
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.super news.com...
should be:

<% rsCheckUser1.Op en strSQL1, adocon1 %>

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

Jul 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2737
by: gonzalo briceno | last post by:
I have been using phplib for a while and I really like the framework except for form creation. Maybe it is me but I in my opinion there isn't a good way to create forms or should I say, everything else is so well done that the way you create forms seems to be too cumbersome, in particular making it so that a pull down menu selects a value that you assign it. In any case, does anyone know of any php based (or other readily accepted web...
2
5398
by: Satvic | last post by:
Hi all, Sorry for HTML, there is a lot of code & comments I tried to create a stored procedure from 3 queries .. to reduce # of times DB gets access from 1 asp page. The result procedure only works 1/2 way (does return the rest of the SELECT statement) :( Please help me figure out what stops it mid way? I need it to return all the results from the SELECT statements AND the number of rows (ScriptsNo) from the count(*): Here is...
8
15234
by: Mike N. | last post by:
Hello: I am new to T-SQL programing, and relativly new to SQL statements in general, although I have a good understanding of database theory. I'm a little confused as to the fundamental differences between a view and a query, or rather, when it is more appropriate to use one vs. the other. It seems to me that most select queries can be implemented as views, and I can't see the downside to doing so.
16
8106
by: chudson007 | last post by:
I have a table, TableA with amongst other fields, a field for Qty. Qty can range from 0 to 100. How do I count the number of rows with a qty between 1 and 10, 11 and 20, 21 and 30, and so on using one SQL statement? Regards, Ciarán
1
2830
by: Good Man | last post by:
Hi there I've noticed some very weird things happening with my current MySQL setup on my XP Laptop, a development machine. For a while, I have been trying to get the MySQL cache to work. Despite entering the required lines to "my.ini" (the new my.cnf) through notepad AND MySQL Administrator, the cache does not work. So, today I took a peek at the 'Health' tab in MySQL Administrator.
17
46564
Motoma
by: Motoma | last post by:
This article is cross posted from my personal blog. You can find the original article, in all its splendor, at http://motomastyle.com/creating-a-mysql-data-abstraction-layer-in-php/. Introduction: The goal of this tutorial is to design a Data Abstraction Layer (DAL) in PHP, that will allow us to ignore the intricacies of MySQL and focus our attention on our Application Layer and Business Logic. Hopefully, by the end of this guide, you will...
1
3519
newnewbie
by: newnewbie | last post by:
Desperately need help in creating a query to count unique values in a table. I am a Business analyst with limited knowledge of Access….My boss got me ODBC connection to the underlying tables for our system and thinks I am omnipotent now and can extract any data out of it in the form he wants….The truth is, though I know SOME Access, I am not a programmer…and many queries that he wants me to do have a potential of being monstrous towers of...
1
4437
by: JosAH | last post by:
Greetings, Introduction This week we start building Query objects. A query can retrieve portions of text from a Library. I don't want users to build queries by themselves, because users make mistakes. Instead, the Library hands out queries to the user given a simple query String. This is how the library does it:
14
17090
by: chadh | last post by:
I have two select queries that need to have a column of line numbers on them. The numbers need to simply be 1 through however many rows there are in the result set. With the data I'm using the result set usually under 100 rows for each query. I've read solutions that involve using the primary key field and a COUNT function. Those have not worked for me as my data set comes from a linked CSV file with no primary key. I'm using a linked CSV...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9954
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7502
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5383
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.