Home > Net >  The problem of SqlParameter
The problem of SqlParameter

Time:09-21

A database table structure is as follows:


id int the growth
The Name nvarchar (200) an empty

Encoder type varbinary nullable

Record the following:

Id name Encoder
1 Peter NULL

In the code, the use of:

SqlParameter param []={
New SqlParameter (" @ the Name ", the item Name),//item. The Name of James
New SqlParameter (" @ Encoder, "item. The Encoder) item. The Encoder or NULL

};
Var strUpdate="UPDATE A SET name=@ name, Encoder=@ Encoder WHERE id=1";
DbHelper. ExecuteNonQuery (strUpdate, CommandType. Text, param);

Above, perform error report: Implicit conversion from data type nvarchar to varbinary is not allowed. Use the CONVERT function to run this query.

Could you tell me how to change parameters should be? Thank you very much!!

CodePudding user response:

Your incoming is an empty string, not NULL

CodePudding user response:

Thank you, have been solved,,

CodePudding user response:

refer to the second floor csover8 response:
thank you, have been solved,,


You're welcome, it's ok it tieba
  • Related