This was working and stopped.
I have a database with one table that has 2 fields, ID - autonumber, and server - text.
I add several records to the db.
I run the following code:
POINTER pReturn,pdbx
int dbH,hSq3,id,count
istring svr[255]
pReturn=dbConnect("Microsoft Access Driver (*.mdb)","test.mdb",";")
IF pReturn=NULL
MESSAGEBOX 0,"Could not connect to OSAA database\n\nPlease check the OSAA Database path, and restart OSAA","Open Database error",@MB_ICONSTOP
ENDIF
hSq3=dbExecSQL(pReturn,"SELECT * FROM zzz ORDER BY ID")
IF LEN(dbGetErrorCode(hSq3))
MESSAGEBOX 0,dbGetErrorText(hSq3),dbGetErrorCode(hSq3)
ENDIF
IF DBGETLAST(hSq3)
dbBindVariable(hSq3,1,id)
dbBindVariable(hSq3,2,svr)
ELSE
MESSAGEBOX 0,"Failed to get last server","ERROR"
ENDIF
MESSAGEBOX 0,str$(id),"debug"
MESSAGEBOX 0,svr,"debug"
count=dbCardinality(pReturn,"zzz")
MESSAGEBOX 0,str$(count),"debug"
It always returns 0 for the ID value. The cardnality returns the number of records.
What am I doing wrong?
attach a copy of your "test.mdb" and I'll see if I can make it work.
I do notice that hSq3 is declared as an int instead of an uint but don't know if that is the problem.
Larry
It would be eaiser for you to make a new db and add the one table.
Table zzz has 2 fields as described above.
You can add data when you create the db.
An empty db is still large (~30K).
If you can not - I will email it to you.
Your problem is with this section:
IF DBGETLAST(hSq3)
dbBindVariable(hSq3,1,id)
dbBindVariable(hSq3,2,svr)
ELSE
MESSAGEBOX 0,"Failed to get last server","ERROR"
ENDIF
You're trying to get the last record of the results before you are binding the variables which means "0" is the correct result for what you are doing.
Change it to this and it should work:
If hSq3
dbBindVariable(hSq3,1,id)
dbBindVariable(hSq3,2,svr)
DBGETLAST(hSq3)
ELSE
MESSAGEBOX 0,"Failed to get last server","ERROR"
ENDIF
That fixed it - owe you a big thanks.
Not sure when I made the change that broke it - must have been when
I was cleaning up the code.
Found a FREE application for repairing MDB.
http://www.softales.com/index_software.php?list=61 (http://www.softales.com/index_software.php?list=61)
Might be of interest.