🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #4284

Re: Append violating primary key???

#4284
From: David Barnes
Date: Wed, 30 Jan 2002 18:12
41 lines
2468 bytes
 > Isn't Insert() supposed to insert an empty
 > record into the database?

Yes and No. It will try to insert a new record, but what you are 
encountering is a Primary Key field not being unique (is my guess). An 
example would be something like this:

If I wanted to have a database of people and I used their Social 
Security Number as a key, I wouldn't want any record to have a duplicate 
SSN#. So I would make this field my Primary Key. Now the Database knows 
that there will be no duplicates and if there is it will throw an 
exception. (Same goes if you are not assigning any value, the second no 
value might give you a error since it would be a duplicate)

I would suggest you looking at your Primary Key and seeing how it is 
being filled.

David


Jens Weiermann wrote:

> Hi! I'm trying to import some data from ascii files into a SQL server
> database. This is the code I'm using:
> 
>                ADOTable1->Insert();
>                ADOTable1->FieldByName("ChipNr")->AsString = ChipNr;
>                ADOTable1->FieldByName("Direction")->AsString = "I";
>                ADOTable1->FieldByName("Date")->AsDateTime =
> StrToDateTime(DatumZeit);
>                ADOTable1->Post();
> 
> However, the ADOTable->Insert() throws an exception, stating that the
> primary key would be violated. Isn't Insert() supposed to insert an empty
> record into the database? I expected the PK violation when issueing the
> Post() statement, not when Insert()ing ...
> Any clues?
> 
> Thanks,
> Jens
> 
Technical Details
Message-ID: <3C583774.4060605@kalos-inc.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!sienna.impulse.net!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews
References: <3c57e998_2@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,db60e3a349385965
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2002-01-30 10:14:09 PST
Message-ID: <3C583774.4060605@kalos-inc.com>
Date: Wed, 30 Jan 2002 12:12:04 -0600
From: David Barnes <david@kalos-inc.com>
User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:0.9.4) Gecko/20011019 Netscape6/6.2
X-Accept-Language: en-us
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.database.ado
Subject: Re: Append violating primary key???
References: <3c57e998_2@dnews>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 65.69.231.139
X-Trace: dnews 1012414306 65.69.231.139 (30 Jan 2002 10:11:46 -0800)
Lines: 43
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!sienna.impulse.net!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews