如何在MS Access数据库中查找表计数 [英] How to Find tables count in MS Access Database
本文介绍了如何在MS Access数据库中查找表计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在该数据库中有ms访问数据库,在这10个表中有10个表,每个表我有10,000条记录,我希望在选择了我需要的表行数之后,通过浏览选择前端的数据库文件.
选择 count(*)来自表名
尝试此示例...
SqlCommand selectCommand = new SqlCommand("SELECT COUNT(*) FROM tablename", thisConnection);
DataSet DsDrpLd = new DataSet(); if (DsDrpLd.Tables[0].Rows.Count > 0) { DsDrpLd.ReadXml(MapPath("../Report.xml")); PagedDataSource objPds = new PagedDataSource(); objPds.DataSource = DsDrpLd.Tables[0].DefaultView; objPds.AllowPaging = true; objPds.PageSize = 20; objPds.CurrentPageIndex = CurrentPage; lblCurrentPage.Text = "Page : " + (CurrentPage + 1).ToString() + " of " + objPds.PageCount.ToString(); totalcount = Convert.ToInt32(objPds.PageCount.ToString()); lblRecords.Text = Convert.ToString(DsDrpLd.Tables[0].Rows.Count); }
I have ms access database in this database i have 10 tables in this 10 tables each table i have 10,000 records i want select this database file in front end through browse after selecting i need that table rows count.
解决方案
Use this query
select count(*) from tablename
try this example...
SqlCommand selectCommand = new SqlCommand("SELECT COUNT(*) FROM tablename", thisConnection);
DataSet DsDrpLd = new DataSet(); if (DsDrpLd.Tables[0].Rows.Count > 0) { DsDrpLd.ReadXml(MapPath("../Report.xml")); PagedDataSource objPds = new PagedDataSource(); objPds.DataSource = DsDrpLd.Tables[0].DefaultView; objPds.AllowPaging = true; objPds.PageSize = 20; objPds.CurrentPageIndex = CurrentPage; lblCurrentPage.Text = "Page : " + (CurrentPage + 1).ToString() + " of " + objPds.PageCount.ToString(); totalcount = Convert.ToInt32(objPds.PageCount.ToString()); lblRecords.Text = Convert.ToString(DsDrpLd.Tables[0].Rows.Count); }
这篇关于如何在MS Access数据库中查找表计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文