Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Delphi Databases > Database unique...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 958 of 986
Post > Topic >>

Database unique ID duplication problem

by Dodgy <Dodgy@[EMAIL PROTECTED] > Feb 6, 2007 at 01:27 PM

Hi,

I'm not sure if this is a Delphi problem, or some "quirk" of MS SQL
server 2005, but it's really causing me agro, so if anyone has ever
seen this, and more im****tantly solved it, I would be very grateful!

I have 2 tables on an MS SQL Server 2005 database. I connect using a
TADOConnection

ConnectionString:Provider=SQLOLEDB.1;Password=*****;Persist Security
Info=True;User ID=*****;Initial Catalog=my_database;Data
Source=my_server_ip

And a TADOQuery which uses the above connection.

I insert 1 record into the first table with

        adoquery1.Open;
        adoquery1.Insert;
        adoquery1.FieldByName('datetime').AsDateTime:=now;

adoquery1.FieldByName('zone').asstring:=Request.ContentFields.values['idcode'];
        adoquery1.FieldByName('type').asstring:='reglist';
        adoquery1.FieldByName('server').asstring:=copy(LocalIP,1,49);
        adoquery1.FieldByName('PA_id').asstring:=''; // TBA, maybe
        adoquery1.Post;
        Log('Link ID '+adoquery1.FieldByName('id').AsString]);

And then I insert some other records into the 2nd table, which I link
to the first table with the "id" field I log above.

The problem is every now and then the id field comes back with
something really out of sequence, and when I look in the database it's
not the id that is associated with the record I just made!

The output of my log procedure shows things like
Link ID 222019
Link ID 222020
Link ID 9719
Link ID 222022
Link ID 222023

Sure enough, when I try to find 9719 in the database, it either
doesn't exist, or it's a really old record from days ago. If I look at
222021 (which I don't have in my log), sure enough I find the record I
inserted, which was re****ted as being 9719.

Any ideas? It's really doing my head in.

Dodgy.
-- 
MUSHROOMS ARE THE OPIATE OF THE MOOSES
 




 4 Posts in Topic:
Database unique ID duplication problem
Dodgy <Dodgy@[EMAIL PR  2007-02-06 13:27:14 
Re: Database unique ID duplication problem
ap <ap@[EMAIL PROTECTE  2007-02-07 00:57:00 
Re: Database unique ID duplication problem
Dodgy <Dodgy@[EMAIL PR  2007-02-07 12:11:23 
Re: Database unique ID duplication problem
Grent <Grent@[EMAIL PR  2007-07-19 00:27:24 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 18:51:19 CDT 2008.