Click here to Skip to main content
15,910,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
Good morning and thank you for your help. I have the following C# code:

userid =@"Master\%Clow%";
cmdGetSqlResult.CommandText = "dbo.GetResultsBasedOnUserID";
cmdGetSqlResult.Parameters.AddWithValue("@MYID", userid);

and the GetResultsBasedOnUserID Stored Procedure looks like below:

SET NOCOUNT ON;
@MYID Char(20)
Select * from XYZtable Where userid = @MYID

When I run it in the Query window of SQLServer MGMT Studio as below,

Select * from XYZtable Where userid = ‘Master\%Clow%’

it works, but if I send the value as a stored proc value from C#, it does not work. Would you please help me solve this issue?

Advanced thank you for your help.
Posted
Updated 17-Jun-11 6:44am
v2

I think issue is with your datatype. Because you are sending special chars so make datatype as Nvarchar instead of Char.

Thanks
 
Share this answer
 
Hello Parwej Ahamad,

Great. It worked. I thank you for your help. Have a nice day.

Regards.
 
Share this answer
 
Comments
Parwej Ahamad 17-Jun-11 13:17pm    
Thanks Dear if my suggestion is working.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900