c# - CSharp ado.net Error converting data type nvarchar to numeric -
suppose have table 3 column
id int name nvarchar(63) age int
and have procedure search row match keyword input.
create procedure usp_search @keyword nvarchar(63) begin sekect * tblpersonal @keyword null or @keyword = age or name n'%'+@keyword+'%' end
when tested sql management tool work fine
declare @return_value int exec @return_value = [dbo].[usp_search] @keyword = null
but when execute in ado.net , pass dbnull.value
sqlparameter had error
"error converting data type nvarchar numeric"
anyone can tell me different ado.net , environment of sql management tool
the problem on line:
or @keyword = age
the column age
integer , @keyword
string. prevent getting error, convert data type of age
string,
or @keyword = cast(age nvarchar(5))
Comments
Post a Comment