计数显示1个额外的记录数. [英] Count shows 1 extra record count.
本文介绍了计数显示1个额外的记录数.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
if (txtcombo.Text == "Form ID")
{
label1.Hide();
Global.Open_DataConn("doc", "conData");
OleDbDataAdapter da = new OleDbDataAdapter("SELECT WCDCH.formid, WCDCH.surname, WCDCH.firstname, WCDCH.midname, WCDCH.ttransid FROM WCDCH INNER JOIN bankdata ON WCDCH.formid = bankdata.formid", Global.conData);
DataSet ds = new DataSet();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
label2.Show();
label4.Visible = true;
label3.Text = dataGridView1.RowCount.ToString();
}
else if (txtcombo.Text == "TransactionID")
{
label2.Hide();
Global.Open_DataConn("doc", "conData");
OleDbDataAdapter da = new OleDbDataAdapter("SELECT WCDCH.formid, WCDCH.surname, WCDCH.firstname, WCDCH.midname, WCDCH.ttransid FROM WCDCH INNER JOIN bankdata ON WCDCH.ttransid = bankdata.ttransid", Global.conData);
DataSet ds = new DataSet();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
label1.Show();
label4.Visible = true;
label3.Text = dataGridView1.RowCount.ToString();
}
else
{
MessageBox.Show("Please,Select option which you want");
}
}
我已经在datagrid中完成了从数据库中获取匹配记录的工作,并从datagrid中显示的结果中对记录进行了计数,但是该计数显示了额外的1条记录.
I have done the get matching record from the database in datagrid and count the record from result shown in the datagrid, But the count shows the 1 extra record count.
推荐答案
将其更改为数据源的行数,而不是网格.它可能已经计入了标题行.
Change it to row count of datasource instead of grid. It might have header row counted in it.
label3.Text = dataGridView1.RowCount.ToString();
label3.Text = ds.Tables[0].Rows.Count.ToString();
更改此内容:
change this :
label3.text = ds.Tables[0].Row.Count.ToString();
然后绑定网格.
and then bind the grid.
这篇关于计数显示1个额外的记录数.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文