Insert record in MS SQL through Delphi 
Author Message
 Insert record in MS SQL through Delphi

Hi!

I've a problem with a property of a field IDENTITY.

I make a field in my database
ID integer IDENTITY(1,1) PRIMARY KEY CLUSTERED,
....

Write code

 Tbl.Insert;
 TblField1.Value := 1;
  Tbl.Post; ===> Exception - "The field "ID" must have a value"

 Set property Required = False of field ID

try
 Tbl.Insert;
 TblField1.Value := 1;
 Tbl.Post; ===> Exception - "The field "ID" must have a value"
except
 on EDataBaseError do Tbl.Post;
end;

My program dosen't message exception, but a flield TblID.Value equal to
zero after
inserting, although there's field ID is not null in my database.

What's my fault? Someone must have decided this problem, because it isn't
to
work with relations MS SQL.

                                hans.mtbank.ru



Wed, 18 Jun 1902 08:00:00 GMT  
 Insert record in MS SQL through Delphi

What version of MSSQL are you using?  There is a technical document on the
Borland/Delphi website (http://www.borland.com ) which deals with posting
records to MSSQL 6.0 and earlier when using an identity field.  Check that
document out and see if that helps.

David Sweeney



Quote:
> Hi!

> I've a problem with a property of a field IDENTITY.

> I make a field in my database
> ID integer IDENTITY(1,1) PRIMARY KEY CLUSTERED,
> ....



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How to insert records into indexed MS-SQL-Tables with Delphi C/S

2. MS-SQL ODBC Blob insert error!

3. Performance of inserts into MS SQL Server

4. TQuery, MS-SQL, ODBC and a failed Insert...

5. Inserting Dates and Times into MS-SQL

6. Q : SQL and INSERT and Multi-Records

7. How to INSERT a RECORD using SQL??

8. inserting lots of records in a sql anywhere database

9. Using SQL to insert record wth memo

10. trapping key violation error when inserting new record using SQL

11. Source: SQL on the fly for Updating, Inserting, and Deleting records

12. Insert record w/SQL Server identity field

 

 
Powered by phpBB® Forum Software