Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - ASP.Net Error
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

ASP.Net Error

 Post Reply Post Reply
Author
Misty View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 February 2002
Location: United States
Status: Offline
Points: 711
Post Options Post Options   Thanks (0) Thanks(0)   Quote Misty Quote  Post ReplyReply Direct Link To This Post Topic: ASP.Net Error
    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

Back to Top
Diep-Vriezer View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
Post Options Post Options   Thanks (0) Thanks(0)   Quote Diep-Vriezer Quote  Post ReplyReply Direct Link To This Post 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.



Edited by Diep-Vriezer
Gone..
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Diep-Vriezer View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
Post Options Post Options   Thanks (0) Thanks(0)   Quote Diep-Vriezer Quote  Post ReplyReply Direct Link To This Post 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..
Back to Top
Misty View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 February 2002
Location: United States
Status: Offline
Points: 711
Post Options Post Options   Thanks (0) Thanks(0)   Quote Misty Quote  Post ReplyReply Direct Link To This Post Posted: 14 May 2004 at 9:51pm
I have this problem fixed. Thank you!
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.