locked
ExecuteScalar Help RRS feed

  • Question

  • User-1316656565 posted
    I just recently downloaded version 2 of the Data Layer Application Blocks and have run into a little bit of a problem with calling the ExecuteScalar function. I'm sure it's something simple that I'm missing but I have been working on this issue for several hours now and thought I might see if I can get some help. When I try the following, (both username & password are strings, Stored Procedure works fine) int intUserID = (int)SqlHelper.ExecuteScalar(connString, "User_getValidateUserID", username, password); I get the following error, System.NullReferenceException: Object reference not set to an instance of an object. When examining the code in VS.NET Debugger, it tells me that the error is a result of having 'arguments do not match parameters for function 'SqlHelper.ExectueScalar''. As far as I can tell, I'm not doing anything wrong. If someone might have an idea as to what my problem is I would greatly appreciate any adivce. Thanks.
    Tuesday, May 11, 2004 6:59 PM

All replies

  • User1635139880 posted
    It looks like you are trying to post 2 parameters to the proc right? if so, you need to create a sqlParameter array to hold those parameters. dim parms(1) as sqlParameter parms(0) = new sqlParameter("@UserName", username) parms(1) = new sqlParameter("@Password", password) int intUserID = (int)SqlHelper.ExecuteScalar(connString, "User_getValidateUserID", parms) This would explain your 'arguments do not match parameters for function' error...
    Tuesday, May 18, 2004 4:01 PM