logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
ODBC2 - SQLFetch() problem

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows development
View previous topic :: View next topic  
Author Message
Flutterby



Joined: 01 May 2012
Posts: 11

PostPosted: Sun Nov 04, 2012 18:42    Post subject: ODBC2 - SQLFetch() problem Reply with quote

Hey there,

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:

Code:
CREATE TABLE DB_PERMADEAD (
   player varchar(64) NOT NULL default '~',
   tag varchar(64) NOT NULL default '~',
   name varchar(64) NOT NULL default '~',
   val text,
   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:
Code:
SELECT name FROM DB_PERMADEAD WHERE player='TESTGSID'
in my SQLite Control Center, it returns a row with name = bPermDead.

However, when I run this through nwscript as follows:
Code:
    string sSQL = "SELECT name FROM " + "DB_PERMADEAD" + " WHERE player='" + "TESTGSID"  + "'";
         PrintString(sSQL);
    SQLExecDirect(sSQL);

    int iFetch = SQLFetch();
    PrintString("iFetch = "+IntToString(iFetch));


I get the following log entries:

- in nwnx_odbc.txt:
Code:
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:
Code:
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.
Back to top
View user's profile Send private message
Flutterby



Joined: 01 May 2012
Posts: 11

PostPosted: Sun Nov 04, 2012 21:13    Post subject: Reply with quote

Never mind.

I failed my save vs. stupidity and was working in a module without SQLInit() on modload.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows development All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group