DbiPutField BDE API DateTime Fields => SQL Server 6.5

Hi everyone,

I'm trying to move records in a CSV text file to a SQL server Database.
Although this message

addresses the problems I am encountering using DbiPutfield, I am open to
other suggestions to

achieve the data transfer. The methods I have looke at so far as follows:

1. BCP (unreliable),
2. TTable using Cached Updates (1000 records per 5 minutes),
3. TQuery using Insert SQL (1000 records per 2 minutes),
4. DbiWriteBlock BDE API call (1000 records per 12 seconds).

The good performance using DbiWriteBlock is the main reason I am using it.

I'm having trouble getting DbiPutfield to allocate a DateTime value to the
record buffer (for a

call to DbiWriteBlock). When I attempt this I get a translation error
exception.

All other datatypes work fine. Also if I use a Paradox or Interbase Database
I don't get an

exception but the subsequent values inserted into the tables display
'00/00/00' ????!!!!

Obviously, the DateTime datatypes are different between remote Server and
the BDE. Is there some

flag in the BDE to perform conversion??

The code I have been experimenting with is as follows (altered excerpt from
BDE32.hlp using the

Customers Table in the Demos database):

// 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;

Any suggestions or hints greatly appreciated.

--
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,U,#5:#0I%3D0Z5D-!4D0-"@``
`
end
end