Joined: 01 May 2012
|Posted: Sun Nov 04, 2012 18:42 Post subject: ODBC2 - SQLFetch() problem
I'm trying to rewrite my module to use a SQLite database instead of the big ugly behemoths Bioware provided, and I'm running into some trouble.
It looks like SQLFetch() always returns 0, even if the query I ran before running SQLFetch returned a value. I tested this by running the same query in my SQLite editor.
As an example, I have a table called DB_PERMADEAD which was created with the following query:
|CREATE TABLE DB_PERMADEAD (
player varchar(64) NOT NULL default '~',
tag varchar(64) NOT NULL default '~',
name varchar(64) NOT NULL default '~',
expire int(11) default NULL,
last timestamp NOT NULL default current_timestamp,
PRIMARY KEY (player,tag,name)
In this table is an entry for player TESTGSID, tag TestName, name bPermDead, val 1, expire 0 and last current_timestamp.
If I run the following query:
in my SQLite Control Center, it returns a row with name = bPermDead.
|SELECT name FROM DB_PERMADEAD WHERE player='TESTGSID' |
However, when I run this through nwscript as follows:
| string sSQL = "SELECT name FROM " + "DB_PERMADEAD" + " WHERE player='" + "TESTGSID" + "'";
int iFetch = SQLFetch();
PrintString("iFetch = "+IntToString(iFetch));
I get the following log entries:
- in nwnx_odbc.txt:
|o Got request: SELECT name FROM DB_PERMADEAD WHERE player='TESTGSID'
o Got request: SELECT val FROM DB_PERMADEAD WHERE player='TESTGSID' AND tag='TestName' AND name='bPermDead'
- and in nwserverlog1.txt:
|SELECT name FROM DB_PERMADEAD WHERE player='TESTGSID'
iFetch = 0
Any idea what could be going on? I'm using Windows 7 64bit, with the most recent ODBC2 library.