Print Page | Close Window

ASP.Net Error

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=10439
Printed Date: 29 March 2026 at 10:25am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: ASP.Net Error
Posted By: Misty
Subject: ASP.Net Error
Date Posted: 14 May 2004 at 4:00pm

I have created an ASP.net web page. I cannot figure out why I am getting the following error:

Data type mismatch in criteria expression.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Data type mismatch in criteria expression.

Source Error:

Line 56: 
Line 57:         'Execute the SQL statement -- using the command object -- to populate the DataReader 
Line 58:         dtrPictures = objCommand.ExecuteReader() 
Line 59: 
Line 60:         'Read the record into the DataReader object

Here's a copy of my code:

   <%@ Page Language="VB" Debug="True" Trace="True" %>

<%@ import Namespace="System.Data" %>

<%@ import Namespace="System.Data.OleDb" %>

<script runat="server">

 

'=========================================================

 

' procedures:

'    DisplayRecord(strPicID as String)

'    Page_Load()

 

'=========================================================== ==

 

'Make this DataReader object module-level in scope so that we

'can bind directly to its field values

dim dtrPictures As OleDbDataReader

 

 

'---------------------------------------------

' name: DisplayRecord(strPicID as String)

'---------------------------------------------

Sub DisplayRecord(strPicID as String)

 

        Dim strConnect As String

        Dim objConnect As New OleDbConnection()

        Dim strSQL as String

        Dim objCommand As New OleDbCommand()

 

 

        Dim databaseName, path

 

        databaseName = "----.mdb"

 

        path = Server.MapPath(".")

        path = Replace(path,"html","database")

 

        'Create Connection object

        strConnect    = "Provider=Microsoft.Jet.OLEDB.4.0;Data " _

                                                    & "Source=" & path & "\" & databaseName




Replies:
Posted By: Diep-Vriezer
Date Posted: 14 May 2004 at 4:04pm

PicID isn't a string right? So handle it like an integer, so

sql = ".. WHERE PicID = " & 50 & " And .."

Without the ' ', since it is an integer.



-------------
Gone..


Posted By: Mart
Date Posted: 14 May 2004 at 4:15pm
If picID is always an integer you should make sure it is an integer by using the integer type, that way nobody can inject malicious code.


Posted By: Diep-Vriezer
Date Posted: 14 May 2004 at 4:18pm

Well, if you request a querystring integer, and it isn't an integer, it will raise an error, so you can also choose to just handle those.



-------------
Gone..


Posted By: Misty
Date Posted: 14 May 2004 at 9:51pm
I have this problem fixed. Thank you!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net