473,583 Members | 3,010 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Writing query statement to Access Database from ASP page

First off I do not know alot about writing queries to an Access
Database from an ASP page. This is why I need help.

I have an Events database for 6 colleges in our metro area. On the
homepage I have to display the next event for each college. That would
give me 6 events listed on the page. I have been trying to figure out
how to write a query statement in my ASP page to select just the most
current event from each college. I have not had any success
whatsoever. Any guideance or help would be appreciated.

Thanks.
Jul 19 '05 #1
4 4011
What's the layout of the database? (See here http://www.aspfaq.com/5006)

Ray at work

"George Stout" <gs****@uscs.ed u> wrote in message
news:c2******** *************** ***@posting.goo gle.com...
First off I do not know alot about writing queries to an Access
Database from an ASP page. This is why I need help.

I have an Events database for 6 colleges in our metro area. On the
homepage I have to display the next event for each college. That would
give me 6 events listed on the page. I have been trying to figure out
how to write a query statement in my ASP page to select just the most
current event from each college. I have not had any success
whatsoever. Any guideance or help would be appreciated.

Thanks.

Jul 19 '05 #2

Do you need to know the next event from todays date ... and do you
have the date for each event in your database ... and do you want the
next event to be todays if there is one, or tomorrows.

you may have to ...

select eventDate, eventCollege, eventName, eventDesc from Events
where eventDate >= Date()
order by eventCollege desc, eventDate desc

I would use getrows, and throw this into an array ... or use my
dbconn.asp script on my site. The array would have the equivaent of 4
columns.

<%
Dim theCollege: theCollege = ""
For row = 0 to ubound(eventsAr ray,2)
If Not theCollege = eventsArray(1,n ) Then
theCollege = eventsArray(1,n )
With Response
.Write "your code display for this record in the array"
End With
End If
%>

-See, the above code has an array.
-theCollege starts as nothin
-the array is ordered by college then by date
-this loop will go through the entire array and only write the first
record for the college ... which will be the one you need ... then it
won't write another until it is the next college.

See?

With more info on your DB structure, I may be able to narrow it down a
bit.

I THINK this will be a faster way than selecting top1 for each college
.... that would be 6 hits to the database each time

PERSONALLY

I would create a text file ... first line with the date, then the next
6 lines with the html for the display of the "next events" ... I would
have a subroutine that ...

-checks to see if the date on the first line = today

-if not, goto code that rewrites the text file from the database to
update it

-else, show the text files html

THIS WOULD SAVE BIG TIME ON YOUR DATABASE

I am a MAJOR FREAK about not using the database if possible.

I would even suggest making that text file an asp file that is
included ...

<!-- #include virtual="/scripts/latestEvents.as p" -->

-if no date
-redirect to rewrite of asp inlclude that does the date check

-else
-nothing ... just show the below html

the include could be like...

<%
Dim theDate
theDate = "1/19/04"
If Not theDate = Date() Then
'// Rewrite this page .. must rewrite the below HTML and the value
for theDate variable to todays
Response.Redire ct("thisPageRew riteUtility.asp ")
End If
'// Else ... no action and it will simply display the html below this
%>
<tr><td>College </td><td>Event</td></tr>
<tr><td>College </td><td>Event</td></tr>
<tr><td>College </td><td>Event</td></tr>
<tr><td>College </td><td>Event</td></tr>
<tr><td>College </td><td>Event</td></tr>
<tr><td>College </td><td>Event</td></tr>


+++++++++++++++ ++++++++++++++= =
This would cause the database to only be hit the first time by the
first user each day ... then would be static from here ... I have used
this technique several times, and it would definately be the fastest
way to have a dynamic, static page =) AND YOU NEED SPEED ...
especially since it is your home page we are talking about.

Brynn
www.coolpier.com

P.S. if you need further assistance, let me know ... if this sounds
too complicated, let me know and I may be able to help further or
write a quick couple of scripts. Contact me at the following link if
need be ...

http://www.coolpier.com/cp/developer/contact.asp




On 20 Jan 2004 10:12:03 -0800, gs****@uscs.edu (George Stout) wrote:
First off I do not know alot about writing queries to an Access
Database from an ASP page. This is why I need help.

I have an Events database for 6 colleges in our metro area. On the
homepage I have to display the next event for each college. That would
give me 6 events listed on the page. I have been trying to figure out
how to write a query statement in my ASP page to select just the most
current event from each college. I have not had any success
whatsoever. Any guideance or help would be appreciated.

Thanks.


Brynn
www.coolpier.com

I participate in the group to help give examples of code.
I do not guarantee the effects of any code posted.
Test all code before use!
Jul 19 '05 #3

I am so glad I have a contact me form, instead of my email address up
.... I got some VERY graphic annoying messages after posting this ...
not from anyone in this post ... just someone that read it ... LOL.

I will have my contactMe tool open for anyone to use ... the new one
has Js validation, a limiter on messages per day, and lets you control
the color scheme ...

test.coolpier.c om


On Tue, 20 Jan 2004 19:00:30 GMT, z@z.com (Brynn) wrote:

Do you need to know the next event from todays date ... and do you
have the date for each event in your database ... and do you want the
next event to be todays if there is one, or tomorrows.

you may have to ...

select eventDate, eventCollege, eventName, eventDesc from Events
where eventDate >= Date()
order by eventCollege desc, eventDate desc

I would use getrows, and throw this into an array ... or use my
dbconn.asp script on my site. The array would have the equivaent of 4
columns.

<%
Dim theCollege: theCollege = ""
For row = 0 to ubound(eventsAr ray,2)
If Not theCollege = eventsArray(1,n ) Then
theCollege = eventsArray(1,n )
With Response
.Write "your code display for this record in the array"
End With
End If
%>

-See, the above code has an array.
-theCollege starts as nothin
-the array is ordered by college then by date
-this loop will go through the entire array and only write the first
record for the college ... which will be the one you need ... then it
won't write another until it is the next college.

See?

With more info on your DB structure, I may be able to narrow it down a
bit.

I THINK this will be a faster way than selecting top1 for each college
... that would be 6 hits to the database each time

PERSONALLY

I would create a text file ... first line with the date, then the next
6 lines with the html for the display of the "next events" ... I would
have a subroutine that ...

-checks to see if the date on the first line = today

-if not, goto code that rewrites the text file from the database to
update it

-else, show the text files html

THIS WOULD SAVE BIG TIME ON YOUR DATABASE

I am a MAJOR FREAK about not using the database if possible.

I would even suggest making that text file an asp file that is
included ...

<!-- #include virtual="/scripts/latestEvents.as p" -->

-if no date
-redirect to rewrite of asp inlclude that does the date check

-else
-nothing ... just show the below html

the include could be like...

<%
Dim theDate
theDate = "1/19/04"
If Not theDate = Date() Then
'// Rewrite this page .. must rewrite the below HTML and the value
for theDate variable to todays
Response.Redire ct("thisPageRew riteUtility.asp ")
End If
'// Else ... no action and it will simply display the html below this
%>
<tr><td>Colleg e</td><td>Event</td></tr>
<tr><td>Colleg e</td><td>Event</td></tr>
<tr><td>Colleg e</td><td>Event</td></tr>
<tr><td>Colleg e</td><td>Event</td></tr>
<tr><td>Colleg e</td><td>Event</td></tr>
<tr><td>Colleg e</td><td>Event</td></tr>


++++++++++++++ +++++++++++++++ ==
This would cause the database to only be hit the first time by the
first user each day ... then would be static from here ... I have used
this technique several times, and it would definately be the fastest
way to have a dynamic, static page =) AND YOU NEED SPEED ...
especially since it is your home page we are talking about.

Brynn
www.coolpier.com

P.S. if you need further assistance, let me know ... if this sounds
too complicated, let me know and I may be able to help further or
write a quick couple of scripts. Contact me at the following link if
need be ...

http://www.coolpier.com/cp/developer/contact.asp




On 20 Jan 2004 10:12:03 -0800, gs****@uscs.edu (George Stout) wrote:
First off I do not know alot about writing queries to an Access
Database from an ASP page. This is why I need help.

I have an Events database for 6 colleges in our metro area. On the
homepage I have to display the next event for each college. That would
give me 6 events listed on the page. I have been trying to figure out
how to write a query statement in my ASP page to select just the most
current event from each college. I have not had any success
whatsoever. Any guideance or help would be appreciated.

Thanks.


Brynn
www.coolpier.com

I participate in the group to help give examples of code.
I do not guarantee the effects of any code posted.
Test all code before use!


Brynn
www.coolpier.com

I participate in the group to help give examples of code.
I do not guarantee the effects of any code posted.
Test all code before use!
Jul 19 '05 #4
I will give this a shot. Reading through it it was a bit confusing to
me. I really appreciate the help. I will let you know in a couple of
days.

Thanks.

George

z@z.com (Brynn) wrote in message news:<40******* *******@news.co mcast.giganews. com>...
Do you need to know the next event from todays date ... and do you
have the date for each event in your database ... and do you want the
next event to be todays if there is one, or tomorrows.

you may have to ...

select eventDate, eventCollege, eventName, eventDesc from Events
where eventDate >= Date()
order by eventCollege desc, eventDate desc

I would use getrows, and throw this into an array ... or use my
dbconn.asp script on my site. The array would have the equivaent of 4
columns.

<%
Dim theCollege: theCollege = ""
For row = 0 to ubound(eventsAr ray,2)
If Not theCollege = eventsArray(1,n ) Then
theCollege = eventsArray(1,n )
With Response
.Write "your code display for this record in the array"
End With
End If
%>

-See, the above code has an array.
-theCollege starts as nothin
-the array is ordered by college then by date
-this loop will go through the entire array and only write the first
record for the college ... which will be the one you need ... then it
won't write another until it is the next college.

See?

With more info on your DB structure, I may be able to narrow it down a
bit.

I THINK this will be a faster way than selecting top1 for each college
... that would be 6 hits to the database each time

PERSONALLY

I would create a text file ... first line with the date, then the next
6 lines with the html for the display of the "next events" ... I would
have a subroutine that ...

-checks to see if the date on the first line = today

-if not, goto code that rewrites the text file from the database to
update it

-else, show the text files html

THIS WOULD SAVE BIG TIME ON YOUR DATABASE

I am a MAJOR FREAK about not using the database if possible.

I would even suggest making that text file an asp file that is
included ...

<!-- #include virtual="/scripts/latestEvents.as p" -->

-if no date
-redirect to rewrite of asp inlclude that does the date check

-else
-nothing ... just show the below html

the include could be like...

<%
Dim theDate
theDate = "1/19/04"
If Not theDate = Date() Then
'// Rewrite this page .. must rewrite the below HTML and the value
for theDate variable to todays
Response.Redire ct("thisPageRew riteUtility.asp ")
End If
'// Else ... no action and it will simply display the html below this
%>
<tr><td>College </td><td>Event</td></tr>
<tr><td>College </td><td>Event</td></tr>
<tr><td>College </td><td>Event</td></tr>
<tr><td>College </td><td>Event</td></tr>
<tr><td>College </td><td>Event</td></tr>
<tr><td>College </td><td>Event</td></tr>


+++++++++++++++ ++++++++++++++= =
This would cause the database to only be hit the first time by the
first user each day ... then would be static from here ... I have used
this technique several times, and it would definately be the fastest
way to have a dynamic, static page =) AND YOU NEED SPEED ...
especially since it is your home page we are talking about.

Brynn
www.coolpier.com

P.S. if you need further assistance, let me know ... if this sounds
too complicated, let me know and I may be able to help further or
write a quick couple of scripts. Contact me at the following link if
need be ...

http://www.coolpier.com/cp/developer/contact.asp




On 20 Jan 2004 10:12:03 -0800, gs****@uscs.edu (George Stout) wrote:
First off I do not know alot about writing queries to an Access
Database from an ASP page. This is why I need help.

I have an Events database for 6 colleges in our metro area. On the
homepage I have to display the next event for each college. That would
give me 6 events listed on the page. I have been trying to figure out
how to write a query statement in my ASP page to select just the most
current event from each college. I have not had any success
whatsoever. Any guideance or help would be appreciated.

Thanks.


Brynn
www.coolpier.com

I participate in the group to help give examples of code.
I do not guarantee the effects of any code posted.
Test all code before use!

Jul 19 '05 #5

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

Similar topics

8
2061
by: Dave | last post by:
Hi all, I've been trying to figure this out for the last day and a half and it has me stumped. I've got a web application that I wrote that keeps track of trading cards I own, and I'm moving it from an Access 2000 database to a SQL Server 2000 database. Everything worked perfectly in Access, but I'm having trouble getting data to display...
11
2123
by: 73blazer | last post by:
We are migrating a customer from Version 7.1 FP3, to Version 8.2 (8.1 FP8). For the most part, things are faster, but there is one query that is much much slower, and it is a query that is used all the time. select ATTR1,ATTR2,ATTR3,ATTR4 from physical.part_list where S_PART_NUMBER like '%KJS%' The widlcard before and after seems to be...
5
2137
by: Rated R1 | last post by:
I wrote this before in the NGs, so I am going to paste the responses that I got and see if someone can please help me. Email me and we can set something up as Id even be willing to pay for your time to get me to learn this procedure: MY ORIGINAL POST: I am trying to create a database for my small business. I have typed a bunch of...
2
1610
by: estafford | last post by:
I am having trouble writing a conditional block using ASP.NET and C#. I am trying to do something like this: 1. if page is PostBack - transfer to another page 2. if not postback - connect to database and get information using a querystring id and create a DataReader (as DR). - generate a Form to display using values from the database...
8
2997
by: Jim in Arizona | last post by:
I've been using an example out of a book to be able to edit the rows in a database. I am getting the following error: ======================================================== ======================================================== Server Error in '/' Application....
3
3284
by: Jim in Arizona | last post by:
I have a gridview that's being populated from an access db query. The problem I'm having is that the date/time fields in access that are populating the gridview are showing both date and time, when the field should only be showing one or the other (date or time). Even on the back end of the database where the column properties are, I have...
2
4523
by: Bob Alston | last post by:
If you have an access form with record source being a straightforward query and where clause in the form definition, will the query be sent to the back end jet/Access database and executed there, withonly the record(s) meeting the criteria being returned to the front end? Is JetShowPlan a good tool to see that this is working? Bob
3
7759
by: mnjkahn via AccessMonster.com | last post by:
I'm running Access 2003, modifying a query that has over 45 fields. When I right click on the field name in Query Design View, and then click Build, Access crashes before the Build window appears. It doesn't happen every time, and using the Zoom window works fine. It appears that it only happens when I want to modify an existing...
32
2666
by: wexx | last post by:
I have been looking for some time now (reading books off Safari, searching through forums,etc) I have found no solution to this problem. I turn to anyone of you that may be able to help me. I'm trying to create a database for work, using Microsoft Access 2003 on Windows XP. I have a product licensing database and it has one table named...
0
7826
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...
0
8182
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. ...
0
8327
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...
0
8193
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...
0
6579
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...
1
5701
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...
0
3843
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1433
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1157
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...

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.