Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server ASP
SQL Server ASP Discussions about ASP programming with Microsoft's SQL Server. For more ASP forums, see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server ASP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 5th, 2008, 04:36 PM
Authorized User
Join Date: Aug 2006
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default Data Mismatch Error

I'm getting a data mismatch error. I've traced it to my startdate and enddate, but can't figure out why.

' First let us create Connection and Recordset objects
Dim sCollege, sProgram, startdate, enddate

' A Function to check if some field entered by user is empty
Function ChkString(string)
    If string = "" Then string = " "
    ChkString = Replace(string, "'", "''")
End Function

startdate = ChkString(Request.Form("startdate"))
enddate = ChkString(Request.Form("enddate"))
sCollege = ChkString(Request.Form("school"))
sProgram = ChkString(Request.Form("program"))

' Open the connection to the ODBC source, in this case
' the Access database
<snipped because I know this is fine>

' Now, create the SQL statement
sSQL = "SELECT Session.Session, CourseInfo.CourseNumber, Reason.Reason, Request.Requestor, Request.Faculty, Request.SummaryOfRequest, Request.SummaryofChangesMade, Request.DateCompleted, CDPM.CDPMName, CourseInfo.College, CourseInfo.Program FROM [Session] INNER JOIN (Reason INNER JOIN (CourseInfo INNER JOIN (CDPM INNER JOIN Request ON CDPM.CDPMID = Request.CDPMID) ON CourseInfo.CourseID = Request.CourseID) ON Reason.ReasonID = Request.ReasonID) ON Session.SessionID = Request.SessionID WHERE College='" & sCollege & "' AND Program='" & sProgram & "' AND DateCompleted >='" & startdate & "' ORDER BY DateCompleted desc"
Anyone have an idea?

BTW, this is connecting to an Access database through ASP.

Thanks in advance,

Old March 18th, 2008, 02:34 AM
Authorized User
Join Date: Sep 2003
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to prabodh_mishra

One of the following should work:
  1. Use CDate() while concatenating sSQL
  2. Check Date variables if it is in acceptable (DD/MM) format for Access DB
  3. Use Access DB in-built Date conversion function in your sSQL string.


Similar Threads
Thread Thread Starter Forum Replies Last Post
hi i got runtime error 13 Type Mismatch error sriharsha345 Access VBA 2 February 21st, 2008 09:30 AM
error 3464 'data type mismatch in criteria express Vince_421 Access VBA 3 May 3rd, 2007 06:45 AM
Data Type Mismatch Error in Criteria Expression mmcdonal Access VBA 2 March 1st, 2007 05:18 PM
Data Type mismatch error clueless_may Access VBA 1 May 5th, 2004 09:16 AM
Data Type Mismatch error transcona Classic ASP Databases 4 June 25th, 2003 07:23 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.