In my mvc application we need to load more than 100000 record at a time but while retrieving such amount of data my browser get crashed..
following is my code
string sql = "SELECT * FROM DBO.MY_TEST_DATA";
//MSSQL CONNECTION STRING
string myCnString = "Data Source=MYIPSERVER;Initial Catalog=my_database;
Persist Security Info=True;User ID=sa;Password=myPwd";
DataTable dt = GetDataTable(myCnString, sql);
//Todo: Use the table data
public DataTable GetDataTable(string cnString, string sql)
{
using (SqlConnection cn = new SqlConnection(cnString))
{
cn.Open();
using (SqlDataAdapter da = new SqlDataAdapter(sql, cn))
{
da.SelectCommand.CommandTimeout = 120;
DataSet ds = new DataSet();
da.Fill(ds);
return ds.Tables[0];
}
}
}
Bhagyashree, It will be much much better to get it done with server side paging. It also improves the performance of the application as well. If you are not aware about how to implement then you can look at here and you can also get more help from Google as well !
Hi you can solve this problem by using the advantages of paging .
Pagination is the process of displaying a huge number of records by splitting them into different pages. This can be better explained by a example. Consider you have 10000 records in a table you want to show them to the end user when he requests. The very simple thing is to display all of them by fetching from database with a simple select * from query. OK fine you are done and your job is over. You have checked in the code... Continue reading
if you want to implement paging without any third party plugin ,kindly refer the following link: https://www.aspsnippets.com/Articles/Paging-Pagination-example-in-ASPNet-MVC.aspx
Hope the information was helpful
Thanks
Karthik
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.