Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: Data Type Mismatch on Dates


Message #1 by "Larry Brennan" <lbrennan1@s...> on Fri, 22 Mar 2002 16:25:25
Im my program I am doing several searches on the database. I have a 
problem with dates. My first search to equal a date gives no error. Works 
fine. A second search to find a date inside a range gives a data type 
mismatch error. I don't know why I would get this here when the equals 
seach does not give this error. Does using two dates instead of one make a 
difference?

ERROR MESSAGE:

Microsoft OLE DB Provider for ODBC Drivers error '80040e07' 
[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria 
expression. 


EQUALS SEARCH CODE (this works fine):

If Request.Form("AlarmDateTime") <> "" AND Request.Form
("ChoiceAlarmDateTime") = "equals" Then

strSQL = "Select * from tblAlarm WHERE (dateAlarm Like'" & datetime & "') 
ORDER BY textLicensePlate"
 
call doConnect ()
call doAlarmsSearch ()	

End if	

INSIDE RANGE CODE (gives error above):

If Request.Form("AlarmDateTime") <> "" AND Request.Form("AlarmDateTime2") 
<> "" AND Request.Form("ChoiceAlarmDateTime") = "insiderange" Then


strSQL = "SELECT * FROM tblAlarm WHERE (dateAlarm  BETWEEN '" & datetime 
& "' AND '" & datetime2 & "') ORDER BY textLicensePlate"
call doConnect ()
call doSearch ()

End if	

DOCONNECT / DOALARMSEARCH CODE:

sub doConnect ()

Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Provider = "MSDataShape"
objConn.Open "DSN=autovu;"
Set objRS = objConn.Execute( strSQL )
end sub

sub doAlarmsSearch ()

    Response.write "<form method='get' ACTION='customers-
buttonchoice.asp'>"

do while objRS.EOF <> true
   Response.write "<tr> <td></td>"
   Response.write "<td>" %>
   <input type='radio' name='lane' value= '<%=objRS ("intAlarmID")%>'<%
Response.write(" checked")%>>  
   <% Response.write  objRS ("textLicensePlate") & "</td>"
   Response.write "<td>" & objRS ("intLaneID") & "</td>"
   Response.write "<td>" & objRS ("dateAlarm") & "</td>"
   Response.write "<td>" & objRS ("textReference") & "</td>"
   Response.write "<td>" & objRS ("intReferenceTypeID") & "</td>"         
   Response.write " <td></td> </tr>"
objRS.MoveNext
loop
objRS.Close
objConn.Close

end sub

Any ideas would be appreciated. (This is my first time using this site)

Thank you
Thunderain


  Return to Index