Board index » delphi » Problem with Identity field in Delphi 2, with ODBC SQL server 6.5 link

Problem with Identity field in Delphi 2, with ODBC SQL server 6.5 link

I am getting an error when I attempt to add a record, with a table object,
to a SQL server database, via an ODBC link. I dont have SQL links. It seems
that it wants soemthing to filled into the identifier field, the only
problem is that if I do that SQL server returns an error that an illegal
attempt was made to insert a field (the identifier field) .

Except for trying a SQL query, is there any other option ?

 

Re:Problem with Identity field in Delphi 2, with ODBC SQL server 6.5 link


When You do an "select * from animals" then you can use : Query.Open; But
when doing an
"insert into .............." then You have to use Query.ExecSQL;

Hope This helps

Felix

Johan L. Botha <j...@iafrica.com> wrote in article
<01bc5a64$92767f00$63921fc4@phoenix>...

Quote
> I am getting an error when I attempt to add a record, with a table
object,
> to a SQL server database, via an ODBC link. I dont have SQL links. It
seems
> that it wants soemthing to filled into the identifier field, the only
> problem is that if I do that SQL server returns an error that an illegal
> attempt was made to insert a field (the identifier field) .

> Except for trying a SQL query, is there any other option ?

Re:Problem with Identity field in Delphi 2, with ODBC SQL server 6.5 link


Kallista has a Tech document that discusses issues with Delphi and MS
SQL 6.5. Goto thier web page (Kallista.com) under Tech and you should be
able to find a document called "Using Delphi with MicroSoft SQL Server
6.0" They mention issues with identity fields.

Steve Finner
OQS Software Design Inc.

Re:Problem with Identity field in Delphi 2, with ODBC SQL server 6.5 link


Johan L. Botha <j...@iafrica.com> wrote in article
<01bc5a64$92767f00$63921fc4@phoenix>...

Quote
> I am getting an error when I attempt to add a record, with a table
object,
> to a SQL server database, via an ODBC link. I dont have SQL links. It
seems
> that it wants soemthing to filled into the identifier field, the only
> problem is that if I do that SQL server returns an error that an illegal
> attempt was made to insert a field (the identifier field) .

> Except for trying a SQL query, is there any other option ?

The "Required" property for this field is set by default. You can turn this
off either by creating field objects at design time (use the fields editor)
and turn "Required" for this field off, or during run time with this code:

        Table1.Fields[F].Required := False;
        F equals the field number.
or
        Table1.FieldByName('name of field').Required := False;

Other Threads