If index is 0 on the first call, the file is opened correctly. The problem is likely somewhere else in the code. The most common problem with VB users of TDBAccess is not allocating the memory for stings correctly. If you use TDBFieldGetValueAsString or GetTableProperies which all return strings in one way of another, you have to initialize the string containers with enough size. The easiest way to do this is using Spaces() function.
For example, when you retrieve table properties, use the following code (syntax might be off a bit):
Code: Select all
Dim Prop As TdbTableProperties
'Initialize a string that will hold table name
Prop.Name = Spaces(4)
'Get properties of the first table in the first file
TDBTableGetProperties(0, 0, Prop)
If you do this in a loop, call Spaces() at the beginning of each iteration.
Thanks a lot for the reply Suchy....
I modified my code for the initializaton part, but I still had an issue, so I investigated a bit more.
Then I realized I was using variables (declared as integer) for the DBindex and FieldIndex parameters in the TDBTableGetProperties function.
I tried with static values instead and it worked right away.
Can't we use variables when calling this function instead of using static dbindex or fieldindex arguments?
EDIT EDIT EDIT EDIT
My bad, I was declaring my variables private, the DLL needs their values so as soon as I declared them Public instead, bingo it worked!
Thanks a lot for your help Suchy! Merry Xmas !