Professional Web Applications Themes

Data type mismatch error assistance please - ASP Database

Hi. Winxp/iis5/dwmx/asp/vb/msaccess I'm trying to update a record based on a cookie existance. I'm getting this error when trying to load the page Microsoft OLE DB Provider for ODBC Drivers (0x80040E07) [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression. /affiliates/set.asp, line 19 I've tripple checked the data types in the database and can't see anything wrong. The field is a simple hit counter and is set to number/long integer The code for the hit counter is as follows <% IF Request.Querystring("Affid") <> "" THEN Response.Cookies("Affidcookie") = Request.Querystring("Affid") Response.Cookies("Affidcookie").Expires = Date + 30 END IF %> <% if(request.querystring("affid") <> ...

Sponsored Links
  1. #1

    Default Data type mismatch error assistance please

    Hi.
    Winxp/iis5/dwmx/asp/vb/msaccess

    I'm trying to update a record based on a cookie existance.

    I'm getting this error when trying to load the page

    Microsoft OLE DB Provider for ODBC Drivers (0x80040E07)
    [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria
    expression.
    /affiliates/set.asp, line 19

    I've tripple checked the data types in the database and can't see anything
    wrong.

    The field is a simple hit counter and is set to number/long integer

    The code for the hit counter is as follows

    <%
    IF Request.Querystring("Affid") <> "" THEN
    Response.Cookies("Affidcookie") = Request.Querystring("Affid")
    Response.Cookies("Affidcookie").Expires = Date + 30
    END IF
    %>

    <%
    if(request.querystring("affid") <> "") then Command1__varid =
    request.querystring("affid")
    IF NOT Request.Querystring("Affid") = "" THEN
    set Command1 = Server.CreateObject("ADODB.Command")
    Command1.ActiveConnection = MM_conn222_STRING
    Command1.CommandText = "UPDATE affiliates SET hits = hits + 1 WHERE Affid
    = '" + Replace(Command1__varid, "'", "''") + "'"
    Command1.CommandType = 1
    Command1.CommandTimeout = 0
    Command1.Prepared = true
    Command1.Execute() 'this is line 19
    END IF
    %>

    Can anyone shed some light on this for me i'm stumped.

    Dan


    Sponsored Links
    Me Guest

  2. #2

    Default Re: Data type mismatch error assistance please

    Sorted it

    I just spotted the fault 2 minutes after posting.

    Thanks anyway

    Dan
    "Me" <co.uk> wrote in message
    news:phx.gbl... 
    Affid 


    Me Guest

  3. #3

    Default Re: Data type mismatch error assistance please

    Me wrote: 

    The only way to debug this is to see the actual query being sent to the
    database:

    Response.Write Command1.commandText
    Response.end

    What you see in the browser window when you run this page should be a valid
    sql statement that can be run without modification 9unless wildcards are
    involved) when you paste it into the SQL View of the Access Query Builder. A
    good exercise would be to create this query yourself using the query
    builder's gui (Design View), verify that it does what you want, then switch
    to SQL View to see what you need to make the sql statement look like when
    you execute it from ASP.

    Incidently, you are going to too much trouble to execute this statement: you
    are using dynamic sql (which is not really recommended, but ... ), not
    passing parameters, so you do not need an explicit Command object. A simple:

    Dim sSQL, cn
    sSQL= "UPDATE affiliates SET hits = hits + 1 WHERE Affid
    = '" + Replace(Command1__varid, "'", "''") + "'"
    'for debugging:
    response.write sSQL

    Set cn=server.createobject("adodb.connection")
    cn.open MM_conn222_STRING
    cn.execute sSQL,,129
    '129 tells ADO that
    '1. you are running a sql statement passed as text, and
    '2. that the query being run does not return records so there is no
    'need for ADO to create a recordset object

    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Guest

  4. #4

    Default Re: Data type mismatch error assistance please

    Hi Bob,

    Thanks for your expert view.

    I'm a novice using Dreamweaver to write the code. Can you recommend a good
    tutorial on asp/vbscript or should I forget that and learn dot.net c#

    What do you think is the best way forward are more people moving over to
    dot.net

    Regards

    Dan

    "Bob Barrows [MVP]" <SPAMcom> wrote in message
    news:phx.gbl... 
    >
    > The only way to debug this is to see the actual query being sent to the
    > database:
    >
    > Response.Write Command1.commandText
    > Response.end
    >
    > What you see in the browser window when you run this page should be a[/ref]
    valid 

    switch 
    you 
    simple: 


    Me Guest

  5. #5

    Default Re: Data type mismatch error assistance please

    Many people woulod suggest skipping to dotnet now instead of learning the
    defunct technology. I would look for inexpensive courses in your area
    because programming in .Net requires a more comprehensive programming
    foundation than vbscript.

    Bob Barrows
    Me wrote: 
    >>
    >> The only way to debug this is to see the actual query being sent to
    >> the database:
    >>
    >> Response.Write Command1.commandText
    >> Response.end
    >>
    >> What you see in the browser window when you run this page should be
    >> a valid sql statement that can be run without modification 9unless
    >> wildcards are involved) when you paste it into the SQL View of the
    >> Access Query Builder. A good exercise would be to create this query
    >> yourself using the query builder's gui (Design View), verify that it
    >> does what you want, then switch to SQL View to see what you need to
    >> make the sql statement look like when you execute it from ASP.
    >>
    >> Incidently, you are going to too much trouble to execute this
    >> statement: you are using dynamic sql (which is not really
    >> recommended, but ... ), not passing parameters, so you do not need
    >> an explicit Command object. A simple:
    >>
    >> Dim sSQL, cn
    >> sSQL= "UPDATE affiliates SET hits = hits + 1 WHERE Affid
    >> = '" + Replace(Command1__varid, "'", "''") + "'"
    >> 'for debugging:
    >> response.write sSQL
    >>
    >> Set cn=server.createobject("adodb.connection")
    >> cn.open MM_conn222_STRING
    >> cn.execute sSQL,,129
    >> '129 tells ADO that
    >> '1. you are running a sql statement passed as text, and
    >> '2. that the query being run does not return records so there is no
    >> 'need for ADO to create a recordset object
    >>
    >> Bob Barrows
    >> --
    >> Microsoft MVP - ASP/ASP.NET
    >> Please reply to the newsgroup. This email account is my spam trap so
    >> I don't check it very often. If you must reply off-line, then remove
    >> the "NO SPAM"[/ref][/ref]

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Guest

  6. #6

    Default Re: Data type mismatch error assistance please

    Is the affid field Numeric or text field ?


    John Guest

  7. #7

    Default Re: Data type mismatch error assistance please

    see www.w3schools.com/asp for on-line help


    John Guest

Similar Threads

  1. Type mismatch error
    By getziggy in forum Coldfusion Database Access
    Replies: 1
    Last Post: March 2nd, 04:55 AM
  2. Access data type mismatch for empty form field
    By createmedia in forum Coldfusion Database Access
    Replies: 5
    Last Post: January 27th, 05:24 PM
  3. data type mismatch error...
    By P_Roberts in forum Coldfusion Database Access
    Replies: 3
    Last Post: November 30th, 04:27 PM
  4. Data type mismatch in criteria expression
    By Captain Ru in forum Coldfusion Database Access
    Replies: 3
    Last Post: July 21st, 05:24 PM
  5. 0x800A000D - Type Mismatch Error
    By Lebone Mogotsi in forum ASP Database
    Replies: 1
    Last Post: October 6th, 11:03 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139