asp.net c#中如何从数据库快速获取超过10 000条记录的数据?

时间:2019-01-30 06:04:53

标签: c# asp.net vb.net web-services sql-server-2008-r2

我正在尝试绑定表中的数据,并且该表中有超过10000条记录。当时重新加载页面时,我在绑定ListView中的数据时遇到了麻烦。

我想绑定得很快。

我尝试使用Web服务进行绑定并仅检索必填字段,但没有加快速度。

public class getHistoryPoperty : System.Web.Services.WebService
{

[WebMethod]
public DataTable Get()
{
        string conString= ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
        using (SqlConnection con = new SqlConnection(conString))
        {


            using (SqlCommand cmd = new SqlCommand("select m.intPlotid,m.strwant,m.strPlotName,m.intTotalPrice,m.strOwnerName,c.strCityName,cat.strCategoryName,s.strSubCategoryName,d.strDistrictName,t.strTalukaName,a.strAreaName,a1.strName,a2.strName from PropertyMaster as m left outer join tblCity as c on m.intCityId=c.intCityId left outer join tblCategory as cat on m.intCategoryId=cat.intCategoryId left outer join tblSubCategory as s on m.intSubCategoryId=s.intSubCategoryId left outer join tblDistrict as d on m.intDistrictId=d.intDistrictId left outer join tblTaluka as t on m.intTalukaId=t.intTalukaId left outer join tblArea as a on m.intAreaId=a.intAreaId left outer join tblAreaTypeMaster as a1 on m.intAreaTypeId=a1.intAreaTypeId left outer join tblAreaTypeMaster as a2 on m.intAreaTypeId1=a2.intAreaTypeId where m.bitIsActive=0 order by m.intPlotId desc ", con))
            {


                using (SqlDataAdapter sda = new SqlDataAdapter())
                {
                    cmd.Connection = con;
                    sda.SelectCommand = cmd;
                    using (DataTable dt = new DataTable())
                    {
                        dt.TableName = "MyTableName";
                        sda.Fill(dt);
                        return dt;
                    }
                }
            }
        }
}
}

0 个答案:

没有答案