Today encountered a problem, with the hope that the program always error carefully check the original is wrong in a string to execute the stored procedure, you can check the N-pass string a little trouble. And the tracking and the breakpoint finally figured out that it was in the stored procedure that the length of the string was not enough to cause part of the string to be truncated. So the length of the string must be long enough to execute the string's stored procedure. Or it's going to be a hassle, huh?
This is the original stored procedure.
The process of declaring a string in my program is as follows:
private String getfilterstring ()
{
String str = "Checkid > 0";
if (Mothpicker1.selectedindex > 0)
{
String strdate = MothPicker1.Date.ToString ("yyyy-mm");
str + = "and convert (varchar), dbo. t_dangersource_check.indate,120) Like '% "+ strdate +" percent "";
}
if (Ddltype.selectedindex > 0)
{
str + = "and dbo. T_dangersource_file.typeid = "+ Ddltype.selectedvalue +" ";
}
if (TxtSourceName.Text.Trim ()! = "" &&!string. IsNullOrEmpty (TxtSourceName.Text.Trim ()))
{
str + = "and dbo. T_dangersource_file.sourcename like '% ' + txtSourceName.Text.Trim () + "percent" ";
}
str + = "and dbo. T_dangersource_file.deptid = ' "+ deptid +" ' ";
return str;
}