Re: TTable.Append problem.
- From: Troll <troll@xxxxxxxxx>
- Date: Fri, 25 Jan 2008 11:35:06 -0800
Karl A. Sørensen wrote:
Our program needs to be able to run against 2 different databases, Pervasive.SQL and MSSQL server. We have earlier used Titan to connect to Pervasive.SQL. Titan have a class TTbTable that's Titan's "TTable" class. To minimize the rewrite of the application, I would like to use TTable to connect to our database on a Pervasive.SQL server og MSSQL server. This would minimize the need to change our code. Our database can be located on a Pervasive.SQL server, or a MSSQL server.
I almost have a working test program, the only difficulty is creating new records in MSSQL server using TTable.Append.
I do this:
myTTable.Append;
myTTable.FieldByName('Name'):='Name';
myTTable.Post;
There are other fields in my table, but I don't want to fill them all. This gives me an exception, telling me that I have to fill all the fields (one by one).
I then tried this:
For i:=0 to myTTable.FieldDefs.Count-1 do
begin
myTTable.FieldDefs[i].Required := false;
End;
myTTable.Append;
myTTable.FieldByName('Name'):='Name';
myTTable.Post;
But I still get the same exception (EDatabaseError: Field "RECNUM" must have a value). Our RECNUM field is a "Identity integer column" in our SQL server database, and so, we should not need to fill in a value for this column/field. If I fill out the RECNUM field, I get another exception, that basically tells me that I should not place anything in this field.
The above code works fine against the Pervasive.SQL database. I can locate, edit and delete records in our MSSQL database, but not insert new records.
TIA
Karl
Setting the Required flag to false won't do much for a table
designed with an autoincrement. The error is likely coming
from your SQL server and it doesn't give a poop about your
flags.
In my applications, I have to set the autoincrement field to
zero in order to have it assign it itself.
Could that be the case?
.
- Follow-Ups:
- Re: TTable.Append problem.
- From: Karl A. Sørensen
- Re: TTable.Append problem.
- References:
- TTable.Append problem.
- From: Karl A. Sørensen
- TTable.Append problem.
- Prev by Date: Send/Receive Email: Point me in the right direction
- Next by Date: Re: Embed image in email
- Previous by thread: TTable.Append problem.
- Next by thread: Re: TTable.Append problem.
- Index(es):
Relevant Pages
|