dbase.executeQuery returns null instead results MSSQL 2005
Posted: 24 Sep 2008, 12:30
Hi there, I got a custom login procedure, in the loginRequest event I call to a stored procedure, but the executeQuery function is returning null almost always, the SP always return results even if the username and password is not found in the database, this is weird, I'm connecting trough an ODBC connection to an SQL SERVER 2005 database, this is the error and the code.
this is the SFS log
if I restart the server, this works correctly, but only for a few times, then the error comes again
Thank you in advance for your help.
this is the SFS log
this is the codeupaepZone.as]: loginRequest <------ the event is fired
[upaepZone.as]: exec dbo.loginSmartfox 'arenas','arenas', 8 <---- I call the stored procedure
[upaepZone.as]: true <------ I'm tracing if the query results object is null
Error in extension [ upaepZone.as ]: TypeError: Cannot call method "get" of null (upaepZone.as#1528) Internal: 45 -- Line number: 44 in file: upaepZone.as <---- this is the error
Code: Select all
var error = ""
trace(evt.name);
if (evt.name == "loginRequest"){
var nick = evt["nick"]
var pass = evt["pass"]
var chan = evt["chan"]
var obj = _server.loginUser(nick, pass, chan) //temporally log the user to get an userId from the smartfox
var response = new Object()
response._typeMessage = "sys"
if (obj.success){
var u = _server.instance.getUserByChannel(chan)
var sqlquery = "exec dbo.loginSmartfox '" + nick + "','"+ pass +"', " + u.getUserId()
trace(sqlquery)
var queryRes = dbase.executeQuery(sqlquery)
trace(queryRes == null)
var tempRow = queryRes.get(0) // the SP is always returning data even if the user is wrong but the result of the query is always null, Why???
if (tempRow.getItem("Type") == "LoginSuccess"){
response._cmd = "logOK"
response.n = nick
response.id = u.getUserId()
response.mod = 0
}else{
//_server.kickUser(u, 15, "invalid username or password") //this is not working
response._cmd = "logKO"
response.err = "Invalid username or password"
}
}else{
response._cmd = "logKO"
response.err = obj.error
}
_server.sendResponse(response, -1, null, chan)
}Thank you in advance for your help.