First of all, in a DataFlex table, the RECORD_NUMBER is always the unique id. While you can assign other DataFlex indexes where the Invoice Number can also be the unquie id, this is something that MUST already be in the structure of the datafile itself, and not something you can choose.
ODBC cursor errors are common because FlexODBC only supports static or forward only type cursors. The work around is to always use ForwardOnly Cursors. For example with ADO keyset cursors we recommend:
With rs .CursorType = CursorTypeEnum.adOpenForwardOnly .LockType = LockTypeEnum.adLockOptimistic .CursorLocation = CursorLocationEnum.adUseServer End With
And just in case you try switching everything to adUseServer, please be aware FlexODBC stored procedure calls like sp_tables only like adUseClient cursor types.
But, some customers have also had to use this combination of variables with VB 6:
Const adOpenStatic = 3 Const adLockOptimistic = 3 Const adUseClient = 3
oRecordset.CursorType = 2 oRecordset.LockType = 3 oRecordset.CursorLocation = adUseClient
To prevent a "Query-based update failed because the row to update could not be found." type error.
As far as the EOF issue is concerned, the problem seems to happen in VB also becasue of the recordset cursor location. As you can see in the below code when the cursorlocation of the tquery is changed to clUseServer rather than the default, it works.....
try itmQuery := TADOQuery.Create(self); itmQuery.Connection := oConn; itmQuery.CursorType := ctDynamic; itmQuery.CursorLocation := clUseServer; itmQuery.LockType := ltOptimistic; itmQuery.SQL.Clear; itmQuery.SQL.Add('Select * from Customer'); itmQuery.Open; if itmQuery.eof then begin showmessage('EOF');; end else begin showmessage('Not EOF'); end; finally itmQuery.Close; itmQuery.free; end;
|