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  Next
 
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related
View previous topic :: View next topic  
Author Message
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Sun Dec 28, 2008 3:55    Post subject: Reply with quote

chris421 wrote:
Gryphyn, YOU ROCK!!!

I'll mess around with it tomorrow.

Thanks.

Smile

EDIT: Doh! I'm using NWN2. This release is for the old game only. PM me if you build one for NWNX4.

Razz

I was expecting a quiet Christmas, it's been everything but...
I'm still working on getting objects as parameters supported.
Close...

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



Joined: 24 Dec 2008
Posts: 10

PostPosted: Sun Dec 28, 2008 14:49    Post subject: Reply with quote

Sorry about this, but still no luck I'm afraid.

This is a pet project though with no time scale, so really, please don't think I'm trying to pressure you. Just trying to give some feedback on what your produced - I hate it at work when we release stuff and users never feedback, especially on problems that they then figure out work arounds for.

the .INI file looks like this:

nwnx_sqlserver.ini

[SQLSERVER]
;++
;Connection
; Required information for creating a connection string
; if trusted=true, windows authentication is used
; otherwise you need a username/pasword combination
;--
instance=192.168.1.21\SQLEXPRESS
database=nwn
trusted=false
username=Test
password=Testing


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


and on start up the nwnx_sqlserver.log reads:

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 [2008-12-28 12:35:15]
o Hooking StoreCampainObject()...not found.
o Hooking RetrieveCampainObject()...not found.
o Configuration
! F:\NeverwinterNights\NWN\nwnx_sqlserver.ini
! Instance: 192.168.1.21\SQLEXPRESS
! Database: nwn
! Trusted Connection
! Driver={SQL Server};Server={192.168.1.21\SQLEXPRESS};Database={nwn};Trusted_Connection=yes;MARS_Connection=yes;
! Logging 2 (everything)
o Connecting to SQLServer
! [28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user ''. The user is not associated with a trusted SQL Server connection.
! [01S00] [Microsoft][ODBC SQL Server Driver]Invalid connection string attribute
* Unable to connect to database


So the ini file is being found and read as the instance path is being set, however dispite the trusted property being set to false and a valid username and password set, it resolves as using a trusted connection.

Thanks for everything you've done so far, its a really promising project Smile
Back to top
View user's profile Send private message
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Mon Dec 29, 2008 10:50    Post subject: Reply with quote

trusted=0
should fix login the problem.

eg.
! C:\NeverwinterNights\nwnx_sqlserver.ini
! Instance: BLACKBOX\XPRESS2008
! Database: Neverwinter Nights
! Username: your_name
! Password: ******
! Driver={SQL Server Native Client 10.0};Server={BLACKBOX\XPRESS2008};Database={Neverwinter Nights};Uid={your_name};Pwd={your_password};MARS_Connection=yes;

**whoops - meant to hide the 'driver' string, so passwords don't appear in the log.

not sure why your Hooking is not working.

and with the latest version,
you can add 'NativeClient' connections (2005 or 2008)
see above example - using 2008


Last edited by Gryphyn on Mon Dec 29, 2008 11:02; edited 1 time in total
Back to top
View user's profile Send private message
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Mon Dec 29, 2008 10:58    Post subject: Reply with quote

Sable wrote:
Sorry about this, but still no luck I'm afraid.

This is a pet project though with no time scale, so really, please don't think I'm trying to pressure you. Just trying to give some feedback on what your produced - I hate it at work when we release stuff and users never feedback, especially on problems that they then figure out work arounds for.

Thanks for everything you've done so far, its a really promising project Smile

NP...
It's more a matter of me getting it back out to the community.
Over at TheFold.org we're using this for our upcoming release. So I get quite a bit of abuse (err feedback) when things go wrong..., I'm just a bit slack bringing the changes back here...

My new job hasn't helped any either - lost 1.5hrs a day to extra travel (the extra pay helps...)

This is one of those things I'll keep around to plug into DragonAge -March/April- when I get a chance Wink And I thought I was done with DAX errors.

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



Joined: 24 Dec 2008
Posts: 10

PostPosted: Mon Dec 29, 2008 18:19    Post subject: Reply with quote

spot on! thanks very much Very Happy
Back to top
View user's profile Send private message
Sable



Joined: 24 Dec 2008
Posts: 10

PostPosted: Thu Jan 01, 2009 19:01    Post subject: Reply with quote

For reference, is there a patch or min SP level you need to be at to run the SQL connection?

I've been getting the error: [24000] [Microsoft][ODBC Driver Manager] Invalid cursor state, whenever I've tried to run a query/stored proc. I've since patched management studio to SP2 (can't beleive I'd forgotten to do it) bu that doesn't appear to help. Are there any components that need adding?
Back to top
View user's profile Send private message
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Fri Jan 02, 2009 8:48    Post subject: Reply with quote

Sable wrote:
For reference, is there a patch or min SP level you need to be at to run the SQL connection?

I've been getting the error: [24000] [Microsoft][ODBC Driver Manager] Invalid cursor state, whenever I've tried to run a query/stored proc. I've since patched management studio to SP2 (can't beleive I'd forgotten to do it) bu that doesn't appear to help. Are there any components that need adding?


I need a little more detail here...
What is the inGame "string" you are executing?

You need something like "{call sp_Procedure}" - the braces are required as is the keyword call.

as an example
Code:
  string sIdent = IntToString(SQLIdentity(oOwner));
  SQLPrepare("{call [nwSetObject] (?,?,?)}");
  SQLBindString(sIdent);
  SQLBindString(sKey);
  SQLBindObject(oObject);
  SQLExecute();
  SQLCommit();


But Invalid Cursor state, seems to indicate something wrong with the connection/session - perhaps post the relevant bits from the log file.

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



Joined: 24 Dec 2008
Posts: 10

PostPosted: Fri Jan 02, 2009 12:46    Post subject: Reply with quote

I'm afraid I'm just being lazy and running:

Code:
void SetGameCalendarFromDB()
{
    int     iYear = iFirstCommonYear;
    int     iMonth = 1;
    int     iDay = 1;
    int     iHour = 1;
    int     iMinute = GetTimeMinute ();
    int     iSecond = GetTimeSecond ();
    int     iMillisecond = GetTimeMillisecond ();

    string sSQL = "EXECUTE dbo.sp_GetCurrentGameDate";
    SQLExecDirect (sSQL);

    if (SQLResult() == 1) {
        iYear = (SQLGetInt (1));
        iMonth = (SQLGetInt (2));
        iDay = (SQLGetInt (3));
        iHour = (SQLGetInt (4));
    }
    SetCalendar (iYear, iMonth, iDay);
    SetTime (iHour, iMinute, iSecond, iMillisecond);

    return;
}


running the proc through management studio returns:

Code:
EXECUTE dbo.sp_GetCurrentGameDate

1410     7   7   0


through the game gives a log entry of:

Code:
o Executing: EXECUTE dbo.sp_GetCurrentGameDate
o EXECUTE: 1
o RESULT: 1
! [24000] [Microsoft][ODBC Driver Manager] Invalid cursor state
! [24000] [Microsoft][ODBC Driver Manager] Invalid cursor state
! [24000] [Microsoft][ODBC Driver Manager] Invalid cursor state
! [24000] [Microsoft][ODBC Driver Manager] Invalid cursor state
Back to top
View user's profile Send private message
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Fri Jan 02, 2009 15:02    Post subject: Reply with quote

You are using #include "nwnx_aspmode" ?
--this contains my version of SQLExecDirect() which will set up the correct connection handles. (it seems that you are; with the log entries)

The error seems to indicate that the 'statement' handle has been released before it should have been.

The other possibility is that this is being called from 'within' an outer SQL query. SetGameCalendarFromDB() is not called within another database query/loop? (*as it will be in the same context)

It's midnight here, let me have a look in the morning.
I recall getting the issue, and resolving it. I just can't recall the specific solution.

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



Joined: 20 Jan 2005
Posts: 431

PostPosted: Sun Jan 04, 2009 1:17    Post subject: Reply with quote

Doh!

try
if (SQLFetch() == 1) instead.

SQLResult() tracks the Success/Failure of the SQL commands (the ODBC results handle)

SQLFetch() advances the 'pointer' to the start of the next row in the result set (the 1st row in your case)
--the error (despite a Google search) is for an 'unknown' or 'pending' result set

If in doubt check with the ODBC documentation.
I've trimmed down the complexity of the parameters, but each NWScript function corresponds to it namesake ODBC function.

{aside}
Your procedure is returning 'columns'?
if it's returning a 'space' separated string you will only SQLGet..() one column

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



Joined: 24 Dec 2008
Posts: 10

PostPosted: Sun Jan 04, 2009 13:12    Post subject: Reply with quote

its returning columns - could have used a simple select statement, but I was playing with simple stored procs and moving up from there.

Thanks for the SQLFetch() info, the function used to use it instead of SQLResult() to first check something valid was returned from the DB (IF NOT SQL_ERROR etc) and I guess to move onto the first row (I didn't write it), but I didn't think the new version returned an error code on a failed retrieve from the DB?

Thanks for the tip Smile
Back to top
View user's profile Send private message
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Sun Jan 04, 2009 13:45    Post subject: Reply with quote

Sable wrote:
its returning columns - could have used a simple select statement, but I was playing with simple stored procs and moving up from there.

Thanks for the SQLFetch() info, the function used to use it instead of SQLResult() to first check something valid was returned from the DB (IF NOT SQL_ERROR etc) and I guess to move onto the first row (I didn't write it), but I didn't think the new version returned an error code on a failed retrieve from the DB?

Thanks for the tip Smile

SQLResult() is to find the result of the ODBC function. - not really needed within the context of NWScript.

In terms of SQLServer it's mainly there for stored procedures. Where the resultset(s) can vary depending on the success or failure of the 'tasks within'. The catch using "EXECUTE sp_?" is that the SQLExecute() will always succeed, regardless of the success/failure of the sp_? itself.

crude example
Code:

create procedure sp_???
begin
  update <tbl> set col = <val> where <cond>
  if @@rowcount = 0
    begin
      select 'zero rows updated'
      return 1 /*failed*/
    end
  select <tbl>.col1, <ref>.col2, <ref>.co3
    from <tbl> inner join <ref> on <tbl>.col = <ref>.col
    where <cond>
  return 0
end

SQLResult() after SQLExecute() will enable you to know which resultset to expect. a singleton column (failure), or a 'table' (success)

Hope that helps some...

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



Joined: 07 Apr 2005
Posts: 53

PostPosted: Fri Feb 06, 2009 8:02    Post subject: Reply with quote

--Poop. Still no ms sql 08 port for nwnx4?

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



Joined: 20 Jan 2005
Posts: 431

PostPosted: Fri Feb 06, 2009 9:09    Post subject: Reply with quote

chris421 wrote:
--Poop. Still no ms sql 08 port for nwnx4?

aye caramba


Sorry, just haven't had time...

Started a new job, and had to re-learn 2000 Wink
Three months in and I'm still not done fixing up the mess I inherited...

But on a brighter note, we're starting to build our 2008 databases,
So I'll get some time to look into the new STREAMing tech, which should make the SCORCO stuff work a little better (or at least faster)

With DA:O around the corner, my NWN interest is flagging.
NWN2 is a joke (or rather Obsidian is) what 3 years now, and they still can't get their act together.

Not forgotten, more a chore at the moment.

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



Joined: 07 Apr 2005
Posts: 53

PostPosted: Sat Feb 07, 2009 6:45    Post subject: Reply with quote

Yup. Dragon Age looks well thought out, nice trailer, voice acting, etc.. But it's singleplayer, which is a shame. Make sure you grab roll-up 3 for 2008. Long list of bugs.

http://support.microsoft.com/kb/960484
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  Next
Page 4 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