Declaration of a string in the "execute string" stored procedure

Source: Internet
Author: User
Tags trim

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;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.