Re: TTable.Append problem.



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?
.



Relevant Pages

  • Re: Resetting User Password
    ... > Please let me know if there's anyway i can reset the ... Can you stop the MSSQL server on the user's machine? ... database files and attach to another MSSQL Server engine without any ... you don't need any password to attach these files. ...
    (microsoft.public.sqlserver.security)
  • TTable.Append problem.
    ... Our program needs to be able to run against 2 different databases, ... Titan have a class TTbTable that's Titan's "TTable" class. ... connect to our database on a Pervasive.SQL server og MSSQL server. ...
    (alt.comp.lang.borland-delphi)
  • Re: TTable.Append problem.
    ... Titan have a class TTbTable that's Titan's "TTable" class. ... connect to our database on a Pervasive.SQL server og MSSQL server. ... I am trying to rewrite using TADOQuery instead. ...
    (alt.comp.lang.borland-delphi)
  • Performance of datatable.select() func against database query or the xquery
    ... Using MsSQL SERVER 2005. ... what i m doing is querying the database only once at the application_start event of the global.asax file and storing the records in dataset...and further no query to database is done for this data. ... wherever I need this data I fetch it from the dataset...through datatable.selectmethod.this is done several time for a single page request and the website is high traffic portal. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Multi threads issue with JDBC running on BEA Weblogic 8.1 SP4
    ... I am trying to update a specific column in a row on MSSQL server 2005 database via MSSQL Server 2005 JDBC Driver. ... 3- When I do this update transaction from one thread, it works and everything going well and data stored successfully in the database but when I run more than ... active connection ...
    (microsoft.public.sqlserver.jdbcdriver)