SQL statement in ASP for Access DB

I have a small ASP app and I want to create a SQL statement that when done I can secure how many hits.
SELECT * from Schedule WHERE official1='" & tid & "

I have a field called gdate in the dbase and I want to find records whose gdate is between form fields start_date and end_date.

One I get that I need to store the number of records that where matched into a field called thits

help..... and Thanks
Matt PinkstonEnterprise ArchitectAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The following SQL will find the records you are looking for:

SELECT * from Schedule WHERE official1='" & tid & " AND (gDate BETWEEN #" &  start_date & "# AND #" & end_Date & "#)"

Open in new window

This SQL will give you a count of records found matching that criteria:

SELECT Count(YourIDField) from Schedule WHERE official1='" & tid & " AND (gDate BETWEEN #" &  start_date & "# AND #" & end_Date & "#)"

Open in new window

(Replace 'YourIDField' with the actual name of your primary key field)

One way I would handle this:
sql="SELECT * from Schedule WHERE official1='" & tid & " AND (gDate BETWEEN #" &  start_date & "# AND #" & end_Date & "#)"

Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open SQL, conn, 3
If RS.EOF Then
    Response.Write "<h3>No Records found matching that selection</h3>" _
           & "<hr></body></html>"
'If records found, get count:
Number of records found:&nbsp;<%=RS.RecordCount%>
End If


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.