ADO Null Referance
-
I have an SqlCommand AuthUser which call a sproc in a database. When I call execute scalar it produces a NullReferanceException. Code below. Thanks. private bool CustomAuthenticate(string username,string password) { AuthUser.Connection = Global.sqlConnection; AuthUser.Parameters[0].Value = username; AuthUser.Parameters[1].Value = password; long ret = (long)AuthUser.ExecuteScalar();//Crashes here return (ret > 0); } Steve Not all who wander are lost...
-
I have an SqlCommand AuthUser which call a sproc in a database. When I call execute scalar it produces a NullReferanceException. Code below. Thanks. private bool CustomAuthenticate(string username,string password) { AuthUser.Connection = Global.sqlConnection; AuthUser.Parameters[0].Value = username; AuthUser.Parameters[1].Value = password; long ret = (long)AuthUser.ExecuteScalar();//Crashes here return (ret > 0); } Steve Not all who wander are lost...
I'm kinda guessing that your stored procedure is returning null....:rolleyes:
-
I'm kinda guessing that your stored procedure is returning null....:rolleyes:
ok...Thanks. Is there a way that I can tell? Steve Not all who wander are lost...
-
ok...Thanks. Is there a way that I can tell? Steve Not all who wander are lost...
Steve Severance wrote: ok...Thanks. Is there a way that I can tell? Yes, not sure if you have tried this, but when you load up SQL Server Enterprise Manager you can run stored procedures from within the Query Analyser tool. Keep in mind that your stored procedure may return results, it may even return multiple results, however the
ExecuteScalar()
method will only extract the first column which could benull
in your case. You may wish to consider using theExecuteReader()
method or changing your stored procedure to check for null values. Nick Parker