473,895 Members | 2,499 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Recordset Query!

AJ
Hi all,

I am trying to execute the following code:

'create recordset object
SET recData = Server.CreateOb ject("ADODB.rec ordset")

'open recordset
recData.Open "exec GetExhibitorsSe archByName 20,38916,38916, 'do'", DataConn,
3, 3

20 = First Param (EventID)
38916 = Second Param (Start Date Int)
38916 = Third Param (End Date Int)
'do' = Fourth Parameter ('Search Criteria')

When executed from ASP this code does not return any info.

However, when i execute the query within access, with the same parameters, i
get the desire results.

Anyone have any thoughts on what i am doing wrong?

Cheers,
Adam
Jul 18 '06 #1
6 1642
Could we please stick with a single thread? Thank you.
More below:
AJ wrote:
Hi all,

I am trying to execute the following code:

'create recordset object
SET recData = Server.CreateOb ject("ADODB.rec ordset")

'open recordset
recData.Open "exec GetExhibitorsSe archByName 20,38916,38916, 'do'",
DataConn, 3, 3

20 = First Param (EventID)
38916 = Second Param (Start Date Int)
38916 = Third Param (End Date Int)
The dates are Ints??? Why is that? What are the actual datatypes of the
fields in your tables?
'do' = Fourth Parameter ('Search Criteria')

When executed from ASP this code does not return any info.

However, when i execute the query within access, with the same
parameters, i get the desire results.

Anyone have any thoughts on what i am doing wrong?
I prefer this technique:

SET recData = Server.CreateOb ject("ADODB.rec ordset")
DataConn.GetExh ibitorsSearchBy Name 20,38916,38916, "do",recDat a

Unfortunately, I have no chance of telling you what the problem is without
seeing some data and the actual sql in the saved query that you are
executing.

--
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 18 '06 #2
AJ
Hi Bob,

The stored queries are below:

I don't think this current problem is directly related to my queries though.

I thought it was a parameter issue, but when i removed all parameters from
the queries (hard coded values into selects) and ran 'exec
GetExhibitorsSe archByName' from asp i still got no results; if i run
GetExhibitorsSe archByName in Access all is well.

Thus it appears to be a problem with the querying method or recordset.

I would use your preferred method, but it doesn't provide much flexibility
when
intergrating with my paging class and generating the sql queries 'exec ....'
dynamically.

My code is based on the suggestions on this page.
http://authors.aspalliance.com/steve...les/sprocs.asp

I am almost at a loss, why this isn't working..

Any other thoughts??

Thanks for you help...and responses so far...!!!!

Cheers,
Adam

ASP:

SET recData = Server.CreateOb ject("ADODB.rec ordset")

'open recordset
recData.Open "exec GetExhibitorsSe archByName 20,38916,38916, 'do'", DataConn,
3, 3

QUERIES:

ExhibitorsSearc hByName
SELECT

c.ID, c.Company_Name, p.[level], 1 As QueryNbr

FROM

(Company AS c LEFT JOIN Sale AS s ON c.ID = s.Company_ID)

LEFT JOIN

Package AS p ON s.Package_ID = p.ID

WHERE

c.Category = 'EXH'

AND

(s.ID = (SELECT Max(ID) FROM Sale WHERE Company_ID = c.ID) Or
IsNull(s.ID))

AND

EXISTS(SELECT Company_ID FROM Event_Company_L ink WHERE Event_ID
=@EventID AND Company_ID = c.ID)

AND

(INT(Start_Date ) <= @StartDate) AND (INT(End_Date) >= @EndDate)

ORDER BY

p.[level] DESC , c.Company_Name, c.ID

UNION SELECT

c.ID, c.Company_Name, p.[level], 2 As QueryNbr

FROM

(Company AS c LEFT JOIN Sale AS s ON c.ID = s.Company_ID)

LEFT JOIN

Package AS p ON s.Package_ID = p.ID

WHERE

c.Category = 'EXH'

AND

(s.ID = (SELECT Max(ID) FROM Sale WHERE Company_ID = c.ID) Or
IsNull(s.ID))

AND

EXISTS(SELECT Company_ID FROM Event_Company_L ink WHERE Event_ID =
@EventID AND Company_ID = c.ID)
ORDER BY c.Company_Name, c.ID;
GetExhibitorsSe archByName

SELECT ID, First(Company_N ame), First([level]), First(QueryNbr)
FROM ExhibitorsSearc hByName
GROUP BY ID
HAVING First(Company_N ame) LIKE '*' & @CompanyName & '*';
Jul 18 '06 #3
Are you using Access? Access doesn't support the Exec command. In
fact, any attempt to try this should have thrown an Invalid Operation
error. Have you got On Error Resume Next on your page?

You should try Bob's method and see if that works. If your query and
parameters return a recordset when run in Access, they should do using
Bob's method from ASP too.

--
Mike Brind
AJ wrote:
Hi Bob,

The stored queries are below:

I don't think this current problem is directly related to my queries though.

I thought it was a parameter issue, but when i removed all parameters from
the queries (hard coded values into selects) and ran 'exec
GetExhibitorsSe archByName' from asp i still got no results; if i run
GetExhibitorsSe archByName in Access all is well.

Thus it appears to be a problem with the querying method or recordset.

I would use your preferred method, but it doesn't provide much flexibility
when
intergrating with my paging class and generating the sql queries 'exec ....'
dynamically.

My code is based on the suggestions on this page.
http://authors.aspalliance.com/steve...les/sprocs.asp

I am almost at a loss, why this isn't working..

Any other thoughts??

Thanks for you help...and responses so far...!!!!

Cheers,
Adam

ASP:

SET recData = Server.CreateOb ject("ADODB.rec ordset")

'open recordset
recData.Open "exec GetExhibitorsSe archByName 20,38916,38916, 'do'", DataConn,
3, 3

QUERIES:

ExhibitorsSearc hByName
SELECT

c.ID, c.Company_Name, p.[level], 1 As QueryNbr

FROM

(Company AS c LEFT JOIN Sale AS s ON c.ID = s.Company_ID)

LEFT JOIN

Package AS p ON s.Package_ID = p.ID

WHERE

c.Category = 'EXH'

AND

(s.ID = (SELECT Max(ID) FROM Sale WHERE Company_ID = c.ID) Or
IsNull(s.ID))

AND

EXISTS(SELECT Company_ID FROM Event_Company_L ink WHERE Event_ID
=@EventID AND Company_ID = c.ID)

AND

(INT(Start_Date ) <= @StartDate) AND (INT(End_Date) >= @EndDate)

ORDER BY

p.[level] DESC , c.Company_Name, c.ID

UNION SELECT

c.ID, c.Company_Name, p.[level], 2 As QueryNbr

FROM

(Company AS c LEFT JOIN Sale AS s ON c.ID = s.Company_ID)

LEFT JOIN

Package AS p ON s.Package_ID = p.ID

WHERE

c.Category = 'EXH'

AND

(s.ID = (SELECT Max(ID) FROM Sale WHERE Company_ID = c.ID) Or
IsNull(s.ID))

AND

EXISTS(SELECT Company_ID FROM Event_Company_L ink WHERE Event_ID =
@EventID AND Company_ID = c.ID)
ORDER BY c.Company_Name, c.ID;
GetExhibitorsSe archByName

SELECT ID, First(Company_N ame), First([level]), First(QueryNbr)
FROM ExhibitorsSearc hByName
GROUP BY ID
HAVING First(Company_N ame) LIKE '*' & @CompanyName & '*';
Jul 18 '06 #4
AJ wrote:
Hi Bob,

The stored queries are below:

I don't think this current problem is directly related to my queries
though.

I thought it was a parameter issue, but when i removed all parameters
from the queries (hard coded values into selects) and ran 'exec
GetExhibitorsSe archByName' from asp i still got no results; if i run
GetExhibitorsSe archByName in Access all is well.

Thus it appears to be a problem with the querying method or recordset.

I would use your preferred method, but it doesn't provide much
flexibility when
intergrating with my paging class and generating the sql queries
'exec ....' dynamically.

My code is based on the suggestions on this page.
http://authors.aspalliance.com/steve...les/sprocs.asp

I am almost at a loss, why this isn't working..

Any other thoughts??
Not until you provide the actual datatypes of the fields in your table.
I'm still flabbergasted that you are attempting to pass dates as
integers.

>
GetExhibitorsSe archByName

SELECT ID, First(Company_N ame), First([level]), First(QueryNbr)
FROM ExhibitorsSearc hByName
GROUP BY ID
HAVING First(Company_N ame) LIKE '*' & @CompanyName & '*';
Actually, here is your problem right here. When running a query via ADO,
even a saved query, you must use the ODBC wildcards, not the Jet
wildcards. Change this to:

HAVING First(Company_N ame) LIKE '%' & @CompanyName & '%';

You might want to save the original version for testing in the Access
environment.

--
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 18 '06 #5
AJ
Hi Bob,

It was the wildcard characters;

1) % works with ASP & ADO but not with Access
2) * works with Access but not with ASP & ADO.

I find this quite bizarre, so thanks for the insight!!!

Regarding the date issue, it didn't right with me either, but while it worked
i didn't really want to tinker with it. As you have already noticed I don't
particularly like Access, & am not all that good at it;

I find it much easier to do things in SQL Server even MySQL, but a new job
has found me working with Access again until they migrate (which is planned).

The intentions of the previous developer in comparing the Dates as INTS
was to remove the fractional part of any given date.

Consequently 01/02/2006 9:00am & 01/02/2006 12:00pm would amount to
01/02/2006.

This article deals with the problem.
http://support.microsoft.com/kb/210276/

I have since changed the implementation:
AND
(DateValue(Star t_Date) <= INT(Now())) AND (DateValue(End_ Date) >=
INT(Now()))

Thanks for your help!!!

Cheers,
Adam

"Bob Barrows [MVP]" wrote:
AJ wrote:
Hi Bob,

The stored queries are below:

I don't think this current problem is directly related to my queries
though.

I thought it was a parameter issue, but when i removed all parameters
from the queries (hard coded values into selects) and ran 'exec
GetExhibitorsSe archByName' from asp i still got no results; if i run
GetExhibitorsSe archByName in Access all is well.

Thus it appears to be a problem with the querying method or recordset.

I would use your preferred method, but it doesn't provide much
flexibility when
intergrating with my paging class and generating the sql queries
'exec ....' dynamically.

My code is based on the suggestions on this page.
http://authors.aspalliance.com/steve...les/sprocs.asp

I am almost at a loss, why this isn't working..

Any other thoughts??
Not until you provide the actual datatypes of the fields in your table.
I'm still flabbergasted that you are attempting to pass dates as
integers.


GetExhibitorsSe archByName

SELECT ID, First(Company_N ame), First([level]), First(QueryNbr)
FROM ExhibitorsSearc hByName
GROUP BY ID
HAVING First(Company_N ame) LIKE '*' & @CompanyName & '*';

Actually, here is your problem right here. When running a query via ADO,
even a saved query, you must use the ODBC wildcards, not the Jet
wildcards. Change this to:

HAVING First(Company_N ame) LIKE '%' & @CompanyName & '%';

You might want to save the original version for testing in the Access
environment.

--
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 18 '06 #6
AJ wrote:
Hi Bob,

It was the wildcard characters;

1) % works with ASP & ADO but not with Access
2) * works with Access but not with ASP & ADO.

I find this quite bizarre, so thanks for the insight!!!

Regarding the date issue, it didn't right with me either, but while
it worked i didn't really want to tinker with it. As you have already
noticed I don't particularly like Access, & am not all that good at
it;

I find it much easier to do things in SQL Server even MySQL, but a
new job has found me working with Access again until they migrate
(which is planned).

The intentions of the previous developer in comparing the Dates as
INTS
was to remove the fractional part of any given date.

Consequently 01/02/2006 9:00am & 01/02/2006 12:00pm would amount to
01/02/2006.

This article deals with the problem.
http://support.microsoft.com/kb/210276/

I have since changed the implementation:
AND
(DateValue(Star t_Date) <= INT(Now())) AND (DateValue(End_ Date) >=
INT(Now()))
If you have an index that includes those fields, I think you will find
that this will be much more efficient:

.... (Start_Date < Date()+1 and End_Date <= Date())

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 18 '06 #7

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

Similar topics

6
3739
by: HKM | last post by:
Hello, I have a query engine that builds the SQL Query to obtain the recordSet. Following is an Exmaple Query that my QueryBuilder outputted SELECT * FROM BookInfo WHERE BookName LIKE '*cobol*' When I use this query to build recordset I get empty recordSet back when the BookInfo table has entries that qualify for this criteria. To
9
4369
by: Dom Boyce | last post by:
Hi First up, I am using MS Access 2002. I have a database which records analyst rating changes for a list of companies on a daily basis. Unfortunately, the database has been set up (by my predecessor, I hasten to add) so that each day it creates a copy of the record for each company, changes the date to today's date, and prompts the user for any changes of ratings on that day. The resulting data table grows by approx 600 records per...
22
2907
by: Gerry Abbott | last post by:
Hi all, I having some confusing effects with recordsets in a recent project. I created several recordsets, each set with the same number of records, and related with an index value. I create a table and add the index value and a value/s from each recordset in turn, into a temporary table, which I used to create a report. I created this with DAO objects, and it worked fine. I use iteration, and the ..movenext command to get the next...
6
6561
by: lenny | last post by:
Hi, I've been trying to use a Sub or Function in VBA to connect to a database, make a query and return the recordset that results from the query. The connection to the database and the query works fine, but passing the resulting recordset back to the sub's caller is not working out.
3
6910
by: Nathan Bloomfield | last post by:
Hi there, I am having difficulty with a piece of code which would work wonders for my application if only the error trapping worked properly. Basically, it works as follows: - adds records from rsSource into rsDest - if it finds a key violation then it deletes the current record from rsDest and adds the new record from rsSource. This works perfectly - but only for the first found duplicate record, it brings up the error
2
2332
by: Lyn | last post by:
Hi, I am opening a form in Continuous mode to list the records from a recordset created in the calling form. The recordset object is declared as Public and is set into the new form's Recordset property during the Open event. According to the VBA Help file, setting the Recordset property may adjust the RecordSource property accordingly. If I set the RecordSource to blank in Design mode, it remains blank when the form is opened even...
13
3493
by: Jan | last post by:
Hi I have a database that I use to keep track of the sales promotions that we send to companies. I normally send a mailing based on a subset of the companies in the database (found using the query: QryICTMassDistribution3) , I then use a form and the code below to create a new record in the corrispondence table to show what corrispondence has been sent to various companies.
2
6086
by: ajspacemanspiff | last post by:
I currently have a solution that requires 2 sub queries, where each of them is convereted into a crosstab query and then I join the crosstab queries to a result. I would like to make this more dynamic and allow for users to filter, and to do so I would like to be able to create the resulting query all in VBA code. I can create a recordset of each inital query, but is there a way to run a query on that, and then subsequently, a query...
11
2750
by: altreed | last post by:
Hi, I am new to ASP, HTML and iis. I have my asp code working so that I can retrieve my desired record from the database. I can place the data on the screen in table form. All works fine. I wish to evaluate one field in the record and depending on the value in that field I wish to change the colour of the line in the table. As
5
5892
by: Henrik | last post by:
The problem is (using MS Access 2003) I am unable to retrieve long strings (255 chars) from calculated fields through a recordset. The data takes the trip in three phases: 1. A custom public function returns a long string. This works. 2. A query has a calculated field based on the custom function above. This works when the query is run directly.
0
9990
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
11250
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10847
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10938
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
10475
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
9653
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
6072
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4695
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
3
3298
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.