Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Recordset Query!

Reply
Thread Tools

Recordset Query!

 
 
AJ
Guest
Posts: n/a
 
      07-18-2006
Hi all,

I am trying to execute the following code:

'create recordset object
SET recData = Server.CreateObject("ADODB.recordset")

'open recordset
recData.Open "exec GetExhibitorsSearchByName 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
 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      07-18-2006
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.CreateObject("ADODB.recordset")
>
> 'open recordset
> recData.Open "exec GetExhibitorsSearchByName 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.CreateObject("ADODB.recordset")
DataConn.GetExhibitorsSearchByName 20,38916,38916,"do",recData

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"


 
Reply With Quote
 
 
 
 
AJ
Guest
Posts: n/a
 
      07-18-2006
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
GetExhibitorsSearchByName' from asp i still got no results; if i run
GetExhibitorsSearchByName 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.CreateObject("ADODB.recordset")

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

QUERIES:

ExhibitorsSearchByName
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_Link 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_Link WHERE Event_ID =
@EventID AND Company_ID = c.ID)
ORDER BY c.Company_Name, c.ID;


GetExhibitorsSearchByName

SELECT ID, First(Company_Name), First([level]), First(QueryNbr)
FROM ExhibitorsSearchByName
GROUP BY ID
HAVING First(Company_Name) LIKE '*' & @CompanyName & '*';


 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      07-18-2006
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
> GetExhibitorsSearchByName' from asp i still got no results; if i run
> GetExhibitorsSearchByName 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.


>
> GetExhibitorsSearchByName
>
> SELECT ID, First(Company_Name), First([level]), First(QueryNbr)
> FROM ExhibitorsSearchByName
> GROUP BY ID
> HAVING First(Company_Name) 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_Name) 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.


 
Reply With Quote
 
Mike Brind
Guest
Posts: n/a
 
      07-18-2006
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
> GetExhibitorsSearchByName' from asp i still got no results; if i run
> GetExhibitorsSearchByName 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.CreateObject("ADODB.recordset")
>
> 'open recordset
> recData.Open "exec GetExhibitorsSearchByName 20,38916,38916,'do'", DataConn,
> 3, 3
>
> QUERIES:
>
> ExhibitorsSearchByName
> 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_Link 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_Link WHERE Event_ID =
> @EventID AND Company_ID = c.ID)
> ORDER BY c.Company_Name, c.ID;
>
>
> GetExhibitorsSearchByName
>
> SELECT ID, First(Company_Name), First([level]), First(QueryNbr)
> FROM ExhibitorsSearchByName
> GROUP BY ID
> HAVING First(Company_Name) LIKE '*' & @CompanyName & '*';


 
Reply With Quote
 
AJ
Guest
Posts: n/a
 
      07-18-2006
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(Start_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
> > GetExhibitorsSearchByName' from asp i still got no results; if i run
> > GetExhibitorsSearchByName 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.
>
>
> >
> > GetExhibitorsSearchByName
> >
> > SELECT ID, First(Company_Name), First([level]), First(QueryNbr)
> > FROM ExhibitorsSearchByName
> > GROUP BY ID
> > HAVING First(Company_Name) 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_Name) 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.
>
>
>

 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      07-18-2006
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(Start_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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP Problem Updating Recordset =?Utf-8?B?a2JyYWQ=?= Microsoft Certification 3 04-10-2004 11:42 AM
recordset error/perl messages gary artim Perl 0 02-06-2004 01:50 AM
RecordSet.Move or RecordSet.AbsolutePosition?? Hung Huynh ASP General 8 09-24-2003 11:07 AM
win32 adodb/mdb; con.execute returns undef and not recordset. Vikas Yadav Perl 0 09-09-2003 09:10 AM
reuse repeater with new recordset Bob ASP .Net 0 07-07-2003 07:03 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57