delphi ado在字段中插入数据会导致主键错误 [英] delphi ado insert data in fields cause primary key error
问题描述
你好,
我有一个访问数据库并连接到使用adoconnection,ado数据集和数据源连接到数据库的Delphi应用程序,我使用db导航器插入更新删除等,问题是(访问数据库具有主键),我插入新记录时必须手动插入主键值,否则我将收到有关唯一字段中的双精度值"的错误,并说明有关主键的某些内容(错误用希腊语表示,因此我会尽可能准确地将其截断) .添加新记录时如何自动插入主键的任何想法?
谢谢
Kyriakos
Hello,
I have an access database and connected to a Delphi application which use adoconnection, ado dataset and datasource to connect to the database, I use a db navigator to insert update delete etc., the problem is (access database has a primary key) that I have to insert primary key value manually when inserting a new record or else I get an error about a "double value in a unique field" and explains something about the primary key (error is in Greek so I trnslate it as exact as I can). Any ideas on how to insert the primary key automaticaly when I add a new record?
Thank you
Kyriakos
推荐答案
您好,您可以将字段数据类型更改为AutoNumber,因此在插入数据集后,主键可以自动填充新数字,然后可以将数据发布到表格.
Hi, you can change your field datatype to AutoNumber so after Inserting to the dataset the primary key can fill with new number automatically and then you can post data to the table.
这篇关于delphi ado在字段中插入数据会导致主键错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!