0

I am re-writing a login process I wrote in Console to a web based application and keep getting hung up when I add the SqlParamater. For some reason it doesn't recogize FirstName and gives the error "The FirstName does not exist in current context".

How can I solve this?

//set the command object so it knows to execute a stored procedure
cmd.CommandType = CommandType.StoredProcedure;

//Doesn't understand line under....
cmd.Parameters.Add(new SqlParameter("@FirstName", FirstName)); 
parmReturnValue = cmd.Parameters.AddWithValue("@UserId", SqlDbType.Int);
parmReturnValue.Direction = ParameterDirection.ReturnValue;

2 Answers 2

1

The variable FirstName that you are passing to the SqlParameter constructor is not recognized - where is it defined?

You need to ensure that this variable is accessible in the scope of the code you posted.

Contrary to the answer by @gov, this has nothing to do with SQL, since you are getting this as a compilation error.

Sign up to request clarification or add additional context in comments.

1 Comment

Correct, I missed the elphant in the room. My FirstName is now txtUserName. Thanks for pointing that out.
1

Please check in the database what name you gave in the stored procedure

@FirstName"

the above should match the argument in stored procedure

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.