开发者

Adding SqlParameter

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 = Pa开发者_如何转开发rameterDirection.ReturnValue;


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.


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

@FirstName"

the above should match the argument in stored procedure

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜