Click here to Skip to main content
15,172,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a stored procedure that has 2 varchar and 4 int parameters. I want to read content of textbox and filter SqlDataSource but when I set all of the parameter type to string and I don't use varchar parameter all the things is right but when I add string parameter do not work;
C#
<SelectParameters>
   <asp:Parameter Name="ProviderBranchID"  DefaultValue="null" Type="Int32"/>
   <asp:Parameter Name="RequestBranchID"   DefaultValue="null"  Type="Int32"/>
   <asp:Parameter Name="CustomerNo"   DefaultValue="null" Type="Int32" />
   <asp:Parameter Name="BoxesTypeCode"  DefaultValue="null" Type="Int32" />
   <asp:Parameter Name="BoxesName"   DefaultValue="null" Type="String" />
</SelectParameters>



and code behind in Selecting event is...

C#
temp1 = TextBox1.Text;
temp2 = TextBox2.Text;
temp3 = TextBox5.Text;
temp4 = TextBox6.Text;
temp5 = TextBox4.Text;
temp6 = TextBoxName.Text;

e.Command.Parameters["@RequestBranchID"].Value = Convert.ToInt32(temp1);
e.Command.Parameters["@ProviderBranchID"].Value = Convert.ToInt32(temp2);
e.Command.Parameters["@CustomerNo"].Value = Convert.ToInt32(temp4);
e.Command.Parameters["@BoxesTypeCode"].Value = Convert.ToInt32(temp5);
e.Command.Parameters["@BoxesName"].Value = temp6;
Posted

1 solution

It consider String as Unicode character. That is the problem. Change to NVarchar in Sql it should go fine.
   

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