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 
 
SQLServer
Goto page Previous  1, 2, 3, 4, 5, 6
 
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related
View previous topic :: View next topic  
Author Message
Dayhawk



Joined: 21 Nov 2009
Posts: 2

PostPosted: Sun Nov 22, 2009 8:19    Post subject: Reply with quote

Thanks Fireboar and Gryphyn for the quick replies.

Gryphyn, your thoughts made me think that perhaps I had something set up wrong. So I decided to check my database, but that was correct. So I followed your instructions very carefully and found a critical part I missed.

"The function SQLServer() should be added to your modules OnLoad()"

I had set my OnLoad() script to "nwnx_sqlserver". Had this failed outright then I probably would had found it eariler. But it actually worked for putting data into the database.

Once I created a new script to call SQLServer(), the fetch worked as expected!!!

Thanks again!

Dayhawk
Back to top
View user's profile Send private message
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Sun Nov 22, 2009 11:21    Post subject: Reply with quote

Dayhawk,
Good to hear.
Back to top
View user's profile Send private message
Balanor



Joined: 13 Jun 2005
Posts: 29

PostPosted: Mon Oct 22, 2012 0:52    Post subject: Server Crash on SQLFetchObject() Reply with quote

Hoping I can get some help here from people who have used these database plugins. I'm using SQL Express 2008, and try the following code on a lever. However, when I use the lever to retrieve the object, it crashes the server. Evil or Very Mad

Code:
#include "nwnx_sqlmode"
void main()
{
  object oPC = GetLastUsedBy();
  if (!GetLocalInt(oPC, "used")) {
    object oCopy = CopyObject(oPC, GetLocation(oPC));
    SQLStoreObject(oPC, "PCCopy"+GetName(oPC), oCopy);
    DestroyObject(oCopy, 1.0);
    SetLocalInt(oPC, "used", 1);
  }
  else SQLFetchObject(oPC, "PCCopy"+GetName(oPC));
}


I understand that these functions wrap the SCO/RCO functions, and in looking at them they apparently store the objects to a NWN dabatase called NWNX. Is that true? Because when I look in the database directory under C:\NeverwinterNights, there are no database files there for a NWNX database. However, I can see a new entry in the nwObjects table, so the SQLStoreObject function is at least doing...something...on the SQL instance.

My nwnx_sqlserver.ini looks like this:
Code:
[SQLSERVER]
;++
;Connection
; Required information for creating a connection string
; if trusted=true, windows authentication is used
; otherwise you need a username/pasword combination
;--
nativeclient=2008
instance=.\NWNSQL
database=nwn
trusted=true
username=your_name
password=your_password

;++
;Logging
; 0=Nothing
; 1=Errors
; 2=Everything
;--
logging=2


And when the crash occurs, this is what I have in the nwnx_sqlserver.log:
Code:
NWNX^2 SQLServer plugin v1.69.2.0
(c) 2008 by Rob Lobbe (Gryphyn@TheFold.org)
visit us at http://www.nwnx.org

o Started [2012-10-21 17:44:29]
o Hooking StoreCampainObject()...hooked at 5d5830
o Hooking RetrieveCampainObject()...hooked at 5d5710
o Configuration
! C:\NeverwinterNights\NWN\nwnx_sqlserver.ini
! Instance: .\NWNSQL
! Database: nwn
! Trusted Connection
! Driver={SQL Server Native Client 10.0};Server={.\NWNSQL};Database={nwn};Trusted_Connection=yes;MARS_Connection=yes;
! Logging 2 (everything)
o Connecting to SQLServer
! [01000] [Microsoft][SQL Server Native Client 10.0][SQL Server]Changed database context to 'nwn'.
! [01000] [Microsoft][SQL Server Native Client 10.0][SQL Server]Changed language setting to us_english.
o Preparing: {call [nwIdentity] (?,?)}
o PREPARE: 1
! Binding[1] BalanorPlayerName
o BIND: 1
! Binding[2] Balanor
o BIND: 1
o Binding Count: (2)
* Binding: (1) String (6) BalanorPlayerName
* Binding: (2) String (7) Balanor
o Executing prepared statement
o EXECUTE: 1
o FETCH: 1
o STRING: 4
o STRING: 0
o COMMIT: 1
‡ New Player Joining Server (RETURNVISIT=1)
o Preparing: {call [nwSetObject] (?,?,?)}
o PREPARE: 1
! Binding[1] 4
o BIND: 1
! Binding[2] PCCopyBalanor
o BIND: 1
! Binding[3] = ~object~ [199396 bytes]
o Binding Count: (3)
* Binding: (1) String (1) 4
* Binding: (2) String (13) PCCopyBalanor
* Binding: (3) Object (199396) <Binary Data...>
o Executing prepared statement
o EXECUTE: 1
o COMMIT: 1

Here I pull the lever the second time to try and retrieve the object
Code:
o Executing prepared statement
o EXECUTE: 1
o COMMIT: 1
o Preparing: {call [nwGetObject] (?,?)}
o PREPARE: 1
! Binding[1] 4
o BIND: 1
! Binding[2] PCCopyBalanor
o BIND: 1
o Binding Count: (2)
* Binding: (1) String (1) 4
* Binding: (2) String (13) PCCopyBalanor
o Executing prepared statement
o EXECUTE: 1
o FETCH: 1
! [01004] [Microsoft][SQL Server Native Client 10.0]String data, right truncation


Can anyone give me some hints/tips/pointers on what I'm doing wrong?
Back to top
View user's profile Send private message
Balanor



Joined: 13 Jun 2005
Posts: 29

PostPosted: Fri Oct 26, 2012 22:39    Post subject: Reply with quote

OK, how about this then: What plugins do I need loaded for the SQL database plugin to work properly?

I found that if I load the ODBC plugin and setup a database to the SQL instance, and enable the scorco option, it no longer crashes the server. But then, nothing gets written to the NWN database in SQL anymore. So maybe it is some combination of plugins that I do not have loading which is causing this crash?
Back to top
View user's profile Send private message
Balanor



Joined: 13 Jun 2005
Posts: 29

PostPosted: Thu Nov 29, 2012 22:13    Post subject: Reply with quote

Well, I guess I'll try once more. So after extensive testing and trial and error I've found that I can retrieve items from the SQL database, but not creatures. And, as stated, while I can save copies of PCs to the database, retrieving them causes the server to crash. So it would definitely appear the problem has to do with the size of the object being stored.

Internet searches on the "String data, right truncation" error that occurs for large objects indicate it is a problem with the Regional Settings for the data source. But as an ODBC connection isn't needed with this plugin, I assume this is something hardcoded, but I am not a programmer by any means, so I really have no idea.

Any advice? Anything at all? Anyone?
Back to top
View user's profile Send private message
Zunath



Joined: 06 Jul 2006
Posts: 183

PostPosted: Thu Dec 25, 2014 21:40    Post subject: Reply with quote

I'm trying to make this compatible for SQL Server 2012 but not having much luck. I noticed in the source code it's checking the specified year and changing the ODBC driver.

I can't modify the source code to include the 2012 ODBC driver because there are dependencies missing. Is there any chance I can get a package with all the required dependencies?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related All times are GMT + 2 Hours
Goto page Previous  1, 2, 3, 4, 5, 6
Page 6 of 6

 
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