DataList Paging (cj168. 2 methods in Dataaccess.magsdb)

Source: Internet
Author: User
access| Paging public ICollection Getsearchresult (String txtsearch, int StartIndex, int PageSize)
{

SqlConnection myconnection = new SqlConnection (configurationsettings.appsettings["ConnectionString"]);
SqlDataAdapter mycommand = new SqlDataAdapter ("Getsearchresult", MyConnection);

MyCommand.SelectCommand.CommandType = CommandType.StoredProcedure;

SqlParameter parametertxtsearch = new SqlParameter ("@txtSearch", SqlDbType.VarChar, 255);
Parametertxtsearch.value = Txtsearch;
MYCOMMAND.SELECTCOMMAND.PARAMETERS.ADD (Parametertxtsearch);

DataSet myDataSet = new DataSet ();

Mycommand.fill (myDataSet, StartIndex, PageSize, "SearchResult");

return mydataset.tables["SearchResult"]. DefaultView;

}


public int Getsearchresultcount (String txtsearch)
{
Int intcount;
intcount = 0;


SqlConnection myconnection = new SqlConnection (configurationsettings.appsettings["ConnectionString"]);
SqlCommand mycommand = new SqlCommand ("Getsearchresultcount", MyConnection);
myCommand.CommandType = CommandType.StoredProcedure;

SqlParameter parametertxtsearch = new SqlParameter ("@txtSearch", SqlDbType.VarChar, 255);
Parametertxtsearch.value = Txtsearch;
MYCOMMAND.PARAMETERS.ADD (Parametertxtsearch);

Myconnection.open ();
SqlDataReader Dr =mycommand.executereader ();

if (Dr. Read ())
{
intcount = Int32.Parse (dr["co"). ToString ());
}
Else
{
intcount = 0;
}

Dr. Close ();
Return intcount;

}

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.