Solved

Update Autonumber field

Posted on 2006-10-23
2
683 Views
Last Modified: 2008-01-16
I have a asp script which pulls a bunch of fields from a access database, one of the fields ia a autonumber field, its not direclty editible in access.

But from asp, I would like to be able to edit this field, I tried but I get the following error message :


[Microsoft][ODBC Microsoft Access Driver] Cannot update 'orderid'; field not updateable.

The reason why i want to update it is becuase my credit card processor does not accept duplicate orderid fields, for example if the cc did not go through the first time it will record the orderid, then for exmaple if i correct the cc numbers and process it again it will come back with a duplicate order recieved, so i thought i could change the orderid filed by adding a -1 in front of the exisitng orderid number and running a update query as follws :

strsql = "UPDATE [ORDER] "
Strsql = Strsql & "SET [orderid]=" & orderidnew & " "
 Strsql = Strsql & "WHERE [orderid] = " & orderid & ""

       datacon.Execute(strSQL)

howver it doesn't seem to want to update the filed since is a autonuber field... any workarounds with this.. i dont want to change the datatype to integer in access, it must remain autonumber, but using some script in asp, i need to be able to change it if needs be.

i am sure there is a way around this. For example

AUTONUMBER is 123,124,125,126

if i want i should be able to change 124 to 124-1 so :
123,124-1,124,126 and the next autonumber remains 127.

tks.

0
Comment
Question by:Ricky11
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 58

Accepted Solution

by:
amit_g earned 500 total points
ID: 17786913
>>i dont want to change the datatype to integer in access, it must remain autonumber,

Then you can't update this field.

If you don't want the change the datatype of this field, you will have to change the workflow a little bit. Mark this created order as cancelled or some status so that you know that this was cancelled and create a new order with same values.

Another rather simple alternative is to add a new field in the order table. Make 0 as default in that field. Send the OrderId-ThisFiledValue to your CC processor as OrderId. So your most orders would become 123-0, 124-0, 125-0 and so on. For the orders that fail to charge the CC for any reason and you need to do it again, update this field to the next number i.e. 1 and then the OrderId sent to the CC processor becomes 125-1. IF that fails again, the next time increment this field again and the OrderId for Cc processor would then be 125-2 and so on. This way you will never have to update the OrderId and the CC processor would always see a unique OrderId.
0
 

Author Comment

by:Ricky11
ID: 17786936
i see interesting.


if i change the datatype to integer, then i would have to code the orderid to increment automaticly correct? dont think i want to to that. would require a lot of changes.

i could re-create the order but then in that case if the cc declines 3 times or 4 times there would be 4 dead orders in the system marked as cancelled, would be a waste of space in the long run.

i am looking in to your 3rd idea of adding a new field, and defaulting to zero.

Let me type outlound... Hmm... If carderror field = declined  then if submiting order again, change counter = counter + 1, then join the orderid field and the counter field together and pass this as the order id ...

okay sounds  like it could work.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Button on Table, name table1 not working 4 43
MS SQL 2008 and stored prodcures and dates 5 35
Use Mid in Html 6 35
Classic ASP - Display returned sql output parameter 9 57
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question