473,770 Members | 7,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using ASP and parametized query

Per a previous suggestion, I'm trying to use a parametized query in Access
2002. The query functions properly in Access. Now I'm trying to call it from
ASP. I'm using code I found at
http://www.xefteri.com/articles/apr302002/default.aspx and trying to adjust
for my needs. I'm getting this error. The query is there and functioning. It
appears that I'm not connecting. Can I get some more insight?
thanks!
------------------------------
Microsoft VBScript runtime (0x800A01A8)
Object required: 'qry_FindSongs 'White'

------------------------------
My connection string is
------------------------------
Dim conn, mdb, mdw, MM_GenKAccess_S TRING

set conn = CreateObject("A DODB.Connection ")
conn.Mode=adMod eRead
mdb = Server.MapPath( "songs.mdb" )
mdw = Server.MapPath( "system.mdw ")

MM_GenKAccess_S TRING = "Provider=Micro soft.Jet.OLEDB. 4.0; " & _
"Data Source=" & mdb & ";" & _
"Jet OLEDB:Database Password=xyz;" & _
"Jet OLEDB:System database=" & mdw

conn.open MM_GenKAccess_S TRING
------------------------------
<% OPTION EXPLICIT %>
<%
Dim T
T = "%"
If (Request("title ") <> "") Then
T = Request("title" )
End If
%>
<%
Dim A
A = "%"
If (Request("artis t") <> "") Then
A = Request("artist ")
End If
%>
<%
Dim C
C = "%"
If (Request("categ ory") <> "") Then
C = Request("catego ry")
End If
%>
<%
Dim TY
TY = "%"
If (Request("type" ) <> "") Then
TY = Request("type")
End If
%>
<%
Dim M
M = "%"
If (Request("manuf ") <> "") Then
M = Request("manuf" )
End If
%>
<%
Dim SA
SA = "%"
If (Request("singl eartist") <> "") Then
SA = Request("single artist")
End If
%>
<%
Dim rsResults
Set rsResults = Server.CreateOb ject("ADODB.Rec ordset")
rsResults.Activ eConnection = MM_GenKAccess_S TRING
rsResults = "qry_FindSo ngs '" & T & "', '" & A & "', '" & C & "', '" & TY &
"', '" & M & "', '" & SA & "'"
rsResults.Open rsResults, 0, 4
%>
Jul 19 '05 #1
9 11775
shank wrote:
Set rsResults = Server.CreateOb ject("ADODB.Rec ordset")
rsResults.Activ eConnection = MM_GenKAccess_S TRING
rsResults = "qry_FindSo ngs '" & T & "', '" & A & "', '" & C & "', '"
& TY & "', '" & M & "', '" & SA & "'"
rsResults.Open rsResults, 0, 4
%>


Do this instead:

dim cn
Set cn=server.creat eobject("adodb. connection")
cn.open MM_GenKAccess_S TRING
Set rsResults = Server.CreateOb ject("ADODB.Rec ordset")
cn.qry_FindSong s T,A,C,TY,M,SA, rsResults

See? No delimiters to worry about.

Bob Barrows

PS. You don't seem to have provided a user name for your connection. Are you
sure you have workgroup security on your database?

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #2
"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote in message
news:uf******** ******@TK2MSFTN GP10.phx.gbl...
shank wrote:
Set rsResults = Server.CreateOb ject("ADODB.Rec ordset")
rsResults.Activ eConnection = MM_GenKAccess_S TRING
rsResults = "qry_FindSo ngs '" & T & "', '" & A & "', '" & C & "', '"
& TY & "', '" & M & "', '" & SA & "'"
rsResults.Open rsResults, 0, 4
%>
Do this instead:

dim cn
Set cn=server.creat eobject("adodb. connection")
cn.open MM_GenKAccess_S TRING
Set rsResults = Server.CreateOb ject("ADODB.Rec ordset")
cn.qry_FindSong s T,A,C,TY,M,SA, rsResults

See? No delimiters to worry about.

Bob Barrows

PS. You don't seem to have provided a user name for your connection. Are

you sure you have workgroup security on your database?

----------------------------------------------
I'm on a local station and the connection string works for all other pages.
I connected with your string, but got no results, where I should be. To be
clear, this string: "cn.qry_FindSon gs T,A,C,TY,M,SA, rsResults" passes the
values of the variables T,A,C,TY,M,SA into the query qry_FindSongs and
returns a recordset rsResults... correct? I'm not getting a return on
rsResults.

I get this error:
Response object, ASP 0185 (0x8002000E)
A default property was not found for the object.

The variables are being filled....
T: water
A: %
C: %
TY: %
M: %
SA: %

<%
dim cn, rsResults
Set cn=Server.Creat eObject("ADODB. connection")
cn.open MM_GenKAccess_S TRING
Set rsResults = Server.CreateOb ject("ADODB.Rec ordset")
cn.qry_FindSong s T,A,C,TY,M,SA, rsResults
%>
Jul 19 '05 #3
shank wrote:
"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote in message
news:uf******** ******@TK2MSFTN GP10.phx.gbl...
shank wrote:
Set rsResults = Server.CreateOb ject("ADODB.Rec ordset")
rsResults.Activ eConnection = MM_GenKAccess_S TRING
rsResults = "qry_FindSo ngs '" & T & "', '" & A & "', '" & C & "', '"
& TY & "', '" & M & "', '" & SA & "'"
rsResults.Open rsResults, 0, 4
%>
Do this instead:

dim cn
Set cn=server.creat eobject("adodb. connection")
cn.open MM_GenKAccess_S TRING
Set rsResults = Server.CreateOb ject("ADODB.Rec ordset")
cn.qry_FindSong s T,A,C,TY,M,SA, rsResults

See? No delimiters to worry about.

Bob Barrows

PS. You don't seem to have provided a user name for your connection.
Are you sure you have workgroup security on your database?

----------------------------------------------
I'm on a local station


I'm not sure what you mean by "local station"
and the connection string works for all other
pages. I connected with your string, but got no results, where I
should be. To be clear, this string: "
It's not a string, it's a call to a method.

cn.qry_FindSong s T,A,C,TY,M,SA, rsResults
" passes the values of the variables T,A,C,TY,M,SA into the
query qry_FindSongs and returns a recordset rsResults... correct?
Correct. it always works for me.
I'm not getting a return on rsResults.

I get this error:
Response object, ASP 0185 (0x8002000E)
A default property was not found for the object.


Does the error message point to this line?

Check to verify that your connection is open

<%
dim cn, rsResults
Set cn=Server.Creat eObject("ADODB. connection")
cn.open MM_GenKAccess_S TRING
if cn.State = 1 then
Set rsResults = Server.CreateOb ject("ADODB.Rec ordset")
cn.qry_FindSong s T,A,C,TY,M,SA, rsResults
else
Response.Write "Connection is not open<BR>"
end if
%>

Your connection string still looks wierd to me. When you open the database
in Access, do you have to supply both a user name and a password? If not,
you are not using workgroup security and you don't need that business about
a system database in your connection string. If you don't have to enter a
password, then your database is not password-protected and the only thing
needed in your connection string is:

MM_GenKAccess_S TRING = "Provider=Micro soft.Jet.OLEDB. 4.0; " & _
"Data Source=" & mdb

If none of these suggestions help, I will need to look at it first-hand.
Would it be possible to send your database to my email address? Or, you can
extract the relevant objects into another database and remove any sensitive
data if that allows you to send it.

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #4

"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote in message
news:Ox******** ********@TK2MSF TNGP11.phx.gbl. ..
shank wrote:
"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote in message
news:uf******** ******@TK2MSFTN GP10.phx.gbl...
shank wrote:
Set rsResults = Server.CreateOb ject("ADODB.Rec ordset")
rsResults.Activ eConnection = MM_GenKAccess_S TRING
rsResults = "qry_FindSo ngs '" & T & "', '" & A & "', '" & C & "', '"
& TY & "', '" & M & "', '" & SA & "'"
rsResults.Open rsResults, 0, 4
%>

Do this instead:

dim cn
Set cn=server.creat eobject("adodb. connection")
cn.open MM_GenKAccess_S TRING
Set rsResults = Server.CreateOb ject("ADODB.Rec ordset")
cn.qry_FindSong s T,A,C,TY,M,SA, rsResults

See? No delimiters to worry about.

Bob Barrows

PS. You don't seem to have provided a user name for your connection.
Are you sure you have workgroup security on your database? ----------------------------------------------
I'm on a local station


I'm not sure what you mean by "local station"
and the connection string works for all other
pages. I connected with your string, but got no results, where I
should be. To be clear, this string: "


It's not a string, it's a call to a method.

cn.qry_FindSong s T,A,C,TY,M,SA, rsResults
" passes the values of the variables T,A,C,TY,M,SA into the
query qry_FindSongs and returns a recordset rsResults... correct?


Correct. it always works for me.
I'm not getting a return on rsResults.

I get this error:
Response object, ASP 0185 (0x8002000E)
A default property was not found for the object.


Does the error message point to this line?

Check to verify that your connection is open

<%
dim cn, rsResults
Set cn=Server.Creat eObject("ADODB. connection")
cn.open MM_GenKAccess_S TRING
if cn.State = 1 then
Set rsResults = Server.CreateOb ject("ADODB.Rec ordset")
cn.qry_FindSong s T,A,C,TY,M,SA, rsResults
else
Response.Write "Connection is not open<BR>"
end if
%>

Your connection string still looks wierd to me. When you open the database
in Access, do you have to supply both a user name and a password? If not,
you are not using workgroup security and you don't need that business

about a system database in your connection string. If you don't have to enter a
password, then your database is not password-protected and the only thing
needed in your connection string is:

MM_GenKAccess_S TRING = "Provider=Micro soft.Jet.OLEDB. 4.0; " & _
"Data Source=" & mdb

If none of these suggestions help, I will need to look at it first-hand.
Would it be possible to send your database to my email address? Or, you can extract the relevant objects into another database and remove any sensitive data if that allows you to send it.

Bob Barrows

---------------------------------------------------
I have narrowed the problem down. The connection is open. I made this small
test code and it works. I created a query in the Access DB that does not
require a variable. And it works....

<%
'this code works and there is no variables
if conn.State = 1 then
Set rsResults = Server.CreateOb ject("ADODB.Rec ordset")
conn.qry_Select Cat, rsResults
Response.Write "Connection is open<BR>"
else
Response.Write "Connection is not open<BR>"
end if
%>

.... Then I created a query that requires 1 simple variable and I get this
error...
"Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record" which suggests to me that the
variables are not getting passed to the query. How can I troubleshoot
further? Thanks!

<%
'I introduce 1 variable and it appears the variable is not getting passed to
the query
C = "fav"
if conn.State = 1 then
Set rsResults = Server.CreateOb ject("ADODB.Rec ordset")
conn.qry_Select Categories C, rsResults
Response.Write "Connection is open<BR>"
else
Response.Write "Connection is not open<BR>"
end if
%>
Jul 19 '05 #5
shank wrote:
this error...
"Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record" which suggests to me
that the variables are not getting passed to the query. How can I
troubleshoot further? Thanks!

<%
'I introduce 1 variable and it appears the variable is not getting
passed to the query
C = "fav"
if conn.State = 1 then
Set rsResults = Server.CreateOb ject("ADODB.Rec ordset")
conn.qry_Select Categories C, rsResults
Response.Write "Connection is open<BR>"
else
Response.Write "Connection is not open<BR>"
end if
%>

Can you show the SQL for the query that accepts the parameter? I suspect
that the query itself is the problem.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #6

"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote in message
news:uw******** *****@TK2MSFTNG P12.phx.gbl...
shank wrote:
this error...
"Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record" which suggests to me
that the variables are not getting passed to the query. How can I
troubleshoot further? Thanks!

<%
'I introduce 1 variable and it appears the variable is not getting
passed to the query
C = "fav"
if conn.State = 1 then
Set rsResults = Server.CreateOb ject("ADODB.Rec ordset")
conn.qry_Select Categories C, rsResults
Response.Write "Connection is open<BR>"
else
Response.Write "Connection is not open<BR>"
end if
%>

Can you show the SQL for the query that accepts the parameter? I suspect
that the query itself is the problem.

-------------------
I cut-n-pasted these from SQL view in Access.
This query requests 1 variable...
SELECT DISTINCT GenKStock.Categ ory
FROM GenKStock INNER JOIN GenKTitles ON GenKStock.Order No =
GenKTitles.Item Number
WHERE (((GenKStock.Ca tegory) Like "*" & [C] & "*"))
ORDER BY GenKStock.Categ ory;

This query has no variables...
SELECT DISTINCT GenKStock.Categ ory
FROM GenKStock INNER JOIN GenKTitles ON GenKStock.Order No =
GenKTitles.Item Number
ORDER BY GenKStock.Categ ory;

This is the original query that I need to work...
SELECT GenKStock.Order No, GenKTitles.Titl e, GenKTitles.Arti st,
GenKStock.Categ ory, GenKStock.Type, GenKStock.Manuf , GenKStock.Singl eArtist,
GenKTitles.mp3F iles
FROM GenKStock INNER JOIN GenKTitles ON GenKStock.Order No =
GenKTitles.Item Number
WHERE (((GenKTitles.T itle) Like "*" & [T] & "*") AND ((GenKTitles.Ar tist)
Like "*" & [A] & "*") AND ((GenKStock.Cat egory) Like "*" & [C] & "*") AND
((GenKStock.Typ e) Like "*" & [TY] & "*") AND ((GenKStock.Man uf) Like "*" &
[M] & "*") AND ((GenKStock.Sin gleArtist) Like "*" & [SA] & "*"));
Jul 19 '05 #7
shank wrote:
WHERE (((GenKStock.Ca tegory) Like "*" & [C] & "*"))
ORDER BY GenKStock.Categ ory;


You have to change the * to % in order to call this query from ADO. It
didn't make sense to me the first time I encountered this issue, either.

Bob barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #8

"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
shank wrote:
WHERE (((GenKStock.Ca tegory) Like "*" & [C] & "*"))
ORDER BY GenKStock.Categ ory;


You have to change the * to % in order to call this query from ADO. It
didn't make sense to me the first time I encountered this issue, either.


Shazam! Very strange. The ASP gets a recordset, but when using the Access
interface, '%' does not yield any results. Oh well I guess. Thanks very very
much!!!!
Jul 19 '05 #9
tomacheski
1 New Member
Hi - I have an extremely similar problem but am using excel vba to try and run a parameter query based on start and end dates, the code I am using looks like this:
Dim rstmonval As adodb.Recordset
Dim wssheet As Worksheet
Dim startdate As Date
Dim enddate As Date
Dim sql As String

startdate = Me.stdate.Text
enddate = Me.endate.Text


'Open Connection to Database
Const ConnectionStrin g As String = _
"Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=C:\docum ents and settings\tom\de sktop\fundhomev 7ak1.mdb;Jet OLEDB:Database Password=xxxxxx "

Dim Connection As adodb.Connectio n
Set Connection = New adodb.Connectio n
Connection.Conn ectionString = ConnectionStrin g
Connection.Open

Debug.Print Connection.Stat e = ObjectStateEnum .adStateOpen

'Define Recordset and access query
'sql = "SELECT tblMonVal.MVID, tblMonVal.MVDat e, tblMonVal.MVUSD Val, tblMonVal.MVAss etID, tblMonVal.MVAss etPX FROM tblmonval WHERE (((tblMonVal.MV Date) is not null and (tblmonval.mvda te) Between '" & startdate & "' And '" & enddate & "')) ORDER BY tblmonval.mvass etid;"

Debug.Print sql

Set rstmonval = New adodb.Recordset
Connection.qryv alsbymonth startdate, enddate, rstmonval
If (Connection.Sta te = ObjectStateEnum .adStateOpen) Then
Connection.Clos e
End If

However - the Jet engine tells me it cannot find this query, despite the fact that it exits....

can anyone give me a clue as to what I am doing wrong?

thanks

Tom
May 24 '06 #10

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

Similar topics

10
2074
by: | last post by:
I am trying to improve the robustness and elegance of my parametized sql statements in ASP 3.0 as they get passed to the sql server SP. Could anyone tell me if there are weaknessess in the way I have written the following code? I have included both the asp code and the sql stored proceducre to tie things togoether....I appreciate any advice on this. It basically is a application to manage static news stories on our site by tracking and...
3
3435
by: StBond | last post by:
Hi everyone, I am new to Access and Visual Basic so things my be getting across a bit cloudy. I only started using VB for one week. I am having a little problem with the database that I am working on. I am working with MS Access 2002. And I am having a problem with one of my charts. I will explain how everything is laid out then go into details.
1
38539
by: GrantS | last post by:
I am unable to get the connection to work with using the app.config file. the connection works when I use 'in line' connection as below: ------------------------------------------------------------------ I have a declaration in the class private OleDbConnection con; Then code in a procedure as below: 1. This works: con = new OleDbConnection
11
2589
by: Dacuna | last post by:
Is it possible to use a recursive function to loop through a recordset faster? I have a table that I need to edit its contents after doing some calculation. The table has one field has an RawData field and a CalcData field. I open the recordset, exctract the RawData and after doing some calculations update the CalcData with the calculated data. In code I have something as follows. dim rs as new ADODB.Recordset dim cmdUpdate as new...
18
4352
by: Jen | last post by:
I'm using Microsoft's own VB.NET FTP Example: http://support.microsoft.com/default.aspx?scid=kb;en-us;832679 I can get the program to create directories, change directories, etc., but I can't get it to upload a file to the FTP server. I just get a "Cannot connect to remote server" error after this TRY: s = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
10
6731
by: Robert | last post by:
How do you get an accurate count of the number of records returned from a query when using linked tables. I have an access 2003 database as a front end to another access 2003 database that contains only tables. I have linked the tables for the front end to the back end database. I am trying to set the recordsource of a form to a query established by the user to narrow the scope but I don't want to display the form if there are no...
6
1400
by: 2005 | last post by:
Hi I have initialized a member as below: class CNode { public: CNode() : m_pNext(0), m_ticketNum(0) {} ---- private: int m_ticketNum; // ticket number of car CarNode *m_pNext;
21
34438
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most obvious of which is the sharing of files. For example, you upload images to a server to share them with other people over the Internet. Perl comes ready equipped for uploading files via the CGI.pm module, which has long been a core module and allows users...
6
1941
by: raylopez99 | last post by:
This thread is about how variables or parameters (including objects) are passed between forms (namely, using parameterized constructors, e.g., to pass an int between forms (e.g., a calling form and a called dialog form) (see below). My question is that though this works fine, and is consistent with everything I learned in C++, is there a 'better' way to pass information, including member variables, objects, and the like, other than...
0
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10004
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9870
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...
0
8886
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5313
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
5450
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3972
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
3576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2817
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.