Administrator

Administrator

  • Tech Writer
  • 2.2k
  • 1.5m

MS SqlHelper class problem

Apr 11 2003 5:58 PM
I have just compiled the Microsoft.ApplicationBlocks.Data project and xcopied the dll into my own project folder and created a reference to it. Now, I'm trying to execute a Stored Procedure on my Sql Server 2000 server. Looks like this: CREATE Procedure spLogin ( @Email nvarchar(200), @Password nvarchar(16), @UserID int OUTPUT ) AS SELECT @UserID = UserID FROM [User] WHERE Email = @Email AND Password = @Password IF @@Rowcount < 1 SELECT @UserID = 0 GO I'm using the following C# code when I try using the SqlHelper class to retrieve the single value: public string Login(string Email, string Password) { SqlParameter[] oParams = new SqlParameter[3]; oParams[0] = new SqlParameter("@Email", System.Data.SqlDbType.NVarChar); oParams[0].Value = Email; oParams[1] = new SqlParameter("@Password", SqlDbType.NVarChar); oParams[1].Value = Password; oParams[2] = new SqlParameter("@UserID", System.Data.SqlDbType.Int); oParams[2].Direction = ParameterDirection.Output; int Test; try { SqlHelper.ExecuteNonQuery("Data Source=localhost;initial catalog=DevFactory;uid=sa;pwd=;", "spLogin", oParams); Test = (int)oParams[2].Value; } catch { Test = 666; } return Test.ToString(); } Now, I know the username and password I provide in the login form are correct, but it returns 666 nevertheless. Ergo, it hits the catch block. Anyone know what could be wrong?? Thanks!

Answers (2)