Incrementing a Long Integer in an Access table

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Incrementing a Long Integer in an Access table

    I am executing the following SQL on an Access table from
    ASP

    UPDATE MYTABLE SET MYCOUNT=(MYCOUNT + 1)


    Unfortunately this seems to add 2! If I add 2 in the code,
    the actual result is +4! If I do -1, then the result is -2.

    If I change MYCOUNT to an Integer from a Long Integer it
    works fine.

    If a create an update query in Access, whatever data type
    MYCOUNT is, it works.

    Not sure where the problem lies ODBC or OLEDB. It seems on
    a web server with MDAC 2.6 it works OK, with MDAC2.7 RTM
    or MDAC 2.7 SP1 Refresh I get the problem.

    I don't want to have to install MDAC 2.8 unless it will
    definitely fix the problem. Reverting to 2.6 is not a
    viable option either. Can anyone advise? Can anyone
    confirm if this is a problem in MDAC 2.8?


    cheers
    madfiddler Guest

  2. Similar Questions and Discussions

    1. #39915 [NEW]: Trying to access the index of an integer should throw a warning
      From: thuejk at gmail dot com Operating system: Linux PHP version: 5.2.0 PHP Bug Type: Feature/Change Request Bug...
    2. #39278 [Opn->Bgs]: strpos($needle, $integer) returns 0 for certain values of $integer
      ID: 39278 Updated by: tony2001@php.net Reported By: matt at raines dot me dot uk -Status: Open +Status: ...
    3. #39278 [NEW]: strpos($needle, $integer) returns 0 for certain values of $integer
      From: matt at raines dot me dot uk Operating system: GNU/Linux 2.4.27 PHP version: 5.1.6 PHP Bug Type: Strings related Bug...
    4. [LONG] Beers in an Access Table
      Hi everybody, Is it possible to build a form looking like an Excel one ? I explain with an example. I want to have a report concerning number...
    5. Error when trying to add an Access DB Record containing a Long Integer type field using OLEDB in ADO.Net
      Hi All, I am trying to add a record to a datatable that is connected to an Access database. I had no trouble with string and date fields, but...
  3. #2

    Default Re: Incrementing a Long Integer in an Access table

    madfiddler wrote:
    > I am executing the following SQL on an Access table from
    > ASP
    >
    > UPDATE MYTABLE SET MYCOUNT=(MYCOUNT + 1)
    >
    >
    > Unfortunately this seems to add 2! If I add 2 in the code,
    > the actual result is +4! If I do -1, then the result is -2.
    >
    I cannot reproduce this (using ADO 2.6). Here is my test code:

    set cn = server.CreateObject("ADODB.Connection")
    cn.Open "provider=microsoft.jet.oledb.4.0;" & _
    "data source=C:\MyDocu~1\W2KMig~1\w2kmigration.mdb"
    cn.Execute "UPDATE MYTABLE SET MYCOUNT=(MYCOUNT + 1)",,129
    set rs=cn.Execute("select MYCOUNT FROM MYTABLE",,1)
    Response.Write rs(0)
    rs.Close:set rs=nothing
    cn.Close:set cn=nothing
    Response.end

    Unfortunately I cannot test this on a machine with 2.7 installed.

    Are you sure you are not executing the query twice?

    Is using a saved query rather than dynamic sql an option? Does the problem
    occur when using a saved query?

    Instead of
    cn.Execute "UPDATE MYTABLE SET MYCOUNT=(MYCOUNT + 1)",,129

    Create a saved query called SavedUpdateQuery using the above sql statement
    and do this:
    cn.SavedUpdateQuery

    HTH.
    Bob Barrows

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows Guest

  4. #3

    Default Re: Incrementing a Long Integer in an Access table


    >madfiddler wrote:
    >> I am executing the following SQL on an Access table from
    >> ASP
    >>
    >> UPDATE MYTABLE SET MYCOUNT=(MYCOUNT + 1)
    >>
    >>
    >> Unfortunately this seems to add 2! If I add 2 in the
    code,
    >> the actual result is +4! If I do -1, then the result
    is -2.
    >>
    Bob Barrows wrote:
    >I cannot reproduce this (using ADO 2.6). Here is my test
    code:
    >
    >set cn = server.CreateObject("ADODB.Connection")
    >cn.Open "provider=microsoft.jet.oledb.4.0;" & _
    >"data source=C:\MyDocu~1\W2KMig~1\w2kmigration.mdb"
    >cn.Execute "UPDATE MYTABLE SET MYCOUNT=(MYCOUNT + 1)",,129
    >set rs=cn.Execute("select MYCOUNT FROM MYTABLE",,1)
    >Response.Write rs(0)
    >rs.Close:set rs=nothing
    >cn.Close:set cn=nothing
    >Response.end
    >
    >Unfortunately I cannot test this on a machine with 2.7
    installed.
    >
    >Are you sure you are not executing the query twice?
    >
    >Is using a saved query rather than dynamic sql an option?
    Does the problem
    >occur when using a saved query?
    >
    >Instead of
    >cn.Execute "UPDATE MYTABLE SET MYCOUNT=(MYCOUNT + 1)",,129
    >
    >Create a saved query called SavedUpdateQuery using the
    above sql statement
    >and do this:
    >cn.SavedUpdateQuery
    >



    I have actually installed MDAC 2.8 on a test machine now
    and I get the same problem.

    Also changing the data type seems to have only temporarily
    fixed things - the bug seems to have come back and is
    intermittent.

    I've scoured all my ASP and this is definitely the only
    place the update of the counter occurs. This was the first
    thing I checked - also the page is not reloading or
    anything strange like that.


    Thanks for the saved query idea Bob I'll give it a try and
    see what happens.


    madfiddler Guest

Posting Permissions

  • You may not post new threads
  • You may 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