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 PinkstonAsked:
Who is Participating?
 
sammySeltzerConnect With a Mentor Commented:
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>"
    Response.End
'If records found, get count:
%>
<br>
Number of records found:&nbsp;<%=RS.RecordCount%>
End If

0
 
mbizupCommented:
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)


0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.