DbiPutField BDE API using DateTime fields SQL server 6.5

Hi everyone,

I'm having trouble using the DbiPutField BDE API call within a Delphi App.

Some background.
I need to batch records (average 600000) from a text file (from AS400) into
a SQL Server Database and of course performance is a major concern.

I'm open to suggestions for different approaches to achieve this. The
methods I have looked at so far are:

1. TTable with CachedUpdates, (1000 records in 5 minutes)
2. TQuery executing Insert SQL statement (1000 records in 2 minutes).
3. BDE API DbiWriteBlock (1000 records in 15 seconds).

At the moment my money is on using DbiWriteBlock. However, when I try to use
DbiPutField to add a DateTime value to the record buffer, I get a
translation exception.  I guess that the DateTime datatypes from SQL Server
and the BDE are not compatible???? Is there some way to configure this??

If I try the same code using a Paradox or Interbase Database, I don't get an
exception, however the resulting DateTime field is displayed as
00/00/00?????????

The code is as follows (altered from BDE32.hlp for DbiWriteBlock and uses
Customers Table from DBDemos):

// start Code

procedure fDbiWriteBlock(Customer: TTable; var RecordsToInsert: Longint);
var
  pRecordsBuf, pTmpBuf: pBYTE;
  Rec: longint;
  CustNo: double;
  bdeDate : DbiDate;
begin
  DbiDa{*word*249}code(bdeDate,06,24,98);
  Randomize;
  GetMem(pRecordsBuf, Customer.RecordSize * RecordsToInsert);
  pTmpBuf := pRecordsBuf;
  try
    for Rec := 1 to RecordsToInsert do
    begin
      CustNo := Random(1000000);
      // Iterate through the entire record buffer filling each individual
record with information
      with Customer do
      begin

        Check(DbiInitRecord(Handle, pTmpBuf));
        Check(DbiPutField(Handle, FieldByName('CustNo').Index + 1, pTmpBuf,
                pBYTE(@CustNo)));
        Check(DbiPutField(Handle, FieldByName('Company').Index + 1, pTmpBuf,
                PChar('Borland International')));
        Check(DbiPutField(Handle, FieldByName('LastInvoiceDate').Index + 1,
pTmpBuf,
                PDbiDate(@bdeDate)));
        Inc(pTmpBuf, RecordSize);
      end;
    end;
    Check(DbiWriteBLock(Customer.Handle, RecordsToInsert, pRecordsBuf));
  finally
    FreeMem(pRecordsBuf, Customer.RecordSize * RecordsToInsert);

  end;
end;

// End Code

Any feedback is greatly appreciated

--
Geoff Feakes
Network Manager
The Wesley Hospital
gfea...@wesley.com.au

--
Geoff Feakes
Network Manager
The Wesley Hospital
gfea...@wesley.com.au

begin 666 Geoff Feakes.vcf
M0D5'24XZ5D-!4D0-"E9%4E-)3TXZ,BXQ#0I..D9E86ME<SM'96]F9@T*1DXZ
M1V5O9F8@1F5A:V5S#0I/4D<Z5&AE(%=E<VQE>2!H;W-P:71A;#M)4T0-"E1)
M5$Q%.DYE='=O<FL@36%N86=E<@T*5$5,.U=/4DL[5D])0T4Z-C$@-R S,C,R
M(#<Y.3<-"E1%3#M73U)+.T9!6#HV,2 W(#,R,S(@-S Y.0T*0412.U=/4DLZ
M.SM#;W)O;F%T:6]N($1R:79E($%U8VAE;F9L;W=E<CM"<FES8F%N93M13$0[
M-# V-CM!=7-T<F%L:6$-"DQ!0D5,.U=/4DL[14Y#3T1)3D<]455/5$5$+5!2
M24Y404),13I#;W)O;F%T:6]N($1R:79E($%U8VAE;F9L;W=E<CTP1#TP04)R
M:7-B86YE+"!13$0@-# V-CTP1#TP04%U<W1R86QI80T*14U!24P[4%)%1CM)
M3E1%4DY%5#IG9F5A:V5S0'=E<VQE>2YC;VTN874-"E)%5CHQ.3DX,#8R-%0P
3,C$S-#5:#0I%3D0Z5D-!4D0-"@``
`
end
end