C # execution of SQL statements in dot net (swoodland Project)

Source: Internet
Author: User
Tags dot net

The execution result of this function is incorrect:
Bytes ----------------------------------------------------------------------------------------------------------------------------
Public ilist <int> getamountoffastnesswindvalueinvillage (string value, string languagecode)
{
String SQL = "(select count (*), species from trees where standard serial number = @ descriagecodeand trunk fullness branches = @ bvalue group by species) Union (select 0, tree Species from trees where tree not in (select tree species from trees where standard region number = '000000' and trunk fullness branches = @ bvalue group by tree) order by tree ";
Ilist <int> amountoffastnesswindvaluevillage = new list <int> ();
Oledbparameter [] parms = new oledbparameter [] {
New oledbparameter (@ villagecodeand, oledbtype. varchar, 50 ),
New oledbparameter (@ bvalue, oledbtype. varchar, 50 )};
Parms [0]. value = value;
Parms [1]. value = languagecode;

Using (oledbdatareader RDR = olehelper. executereader (olehelper. connectionstring, commandtype. Text, SQL, parms ))
{
While (RDR. Read ())
{
Amountoffastnesswindvaluevillage. Add (RDR. getint32 (0 ));
}
}

Return amountoffastnesswindvaluevillage;
}
Bytes -----------------------------------------------------------------------------------------------------------------------------
Modify this function and the execution result is correct:
Bytes -----------------------------------------------------------------------------------------------------------------------------
Public ilist <int> getamountoffastnesswindvalueinvillage (string languagecode)
{
String SQL = "(select count (*), species from trees where standard serial number = @ villagecodeand trunk fullness branches = 'out' group by species) Union (select 0, tree from trees where tree not in (select tree from trees where standard region no. = @ villagecodeand and trunk fullness branches = 'you' group by tree) order by tree ";
Ilist <int> amountoffastnesswindvaluevillage = new list <int> ();
Oledbparameter parm = new oledbparameter (@ brief agecodeand, oledbtype. varchar, 50 );
Parms [1]. value = languagecode;

Using (oledbdatareader RDR = olehelper. executereader (olehelper. connectionstring, commandtype. Text, SQL, parm ))
{
While (RDR. Read ())
{
Amountoffastnesswindvaluevillage. Add (RDR. getint32 (0 ));
}
}

Return amountoffastnesswindvaluevillage;
}
Bytes -----------------------------------------------------------------------------------------------------------------------------
I don't know why.

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.