我的代码有点混乱。我不知道有什么问题。我在网上搜索了一下,答案是我需要过滤datagridview并显示数据库中的精确值。但是如果我把代码和数据集dataadapter的更改放在一起,就什么都不管用了。如何筛选值?
这是我的密码。
表1,代码1,datagridview 1。
public void DataView()
{
Connection.Open();
MySqlCommand Command = new MySqlCommand("Select * From clientaccountcreditdebitdb", Connection);
DataTable dt = new DataTable();
MySqlDataAdapter da = new MySqlDataAdapter(Command);
da.Fill(dt);
dgvCreditList.DataSource = null;
dgvCreditList.AllowUserToAddRows = false;
dgvCreditList.AutoGenerateColumns = false;
dgvCreditList.ColumnCount = 9;
dgvCreditList.Columns[0].HeaderText = "id";
dgvCreditList.Columns[0].DataPropertyName = "ID";
dgvCreditList.Columns[1].HeaderText = "Account Name";
dgvCreditList.Columns[1].DataPropertyName = "CreditAccountName";
dgvCreditList.Columns[2].HeaderText = "Account Number";
dgvCreditList.Columns[2].DataPropertyName = "CreditAccountNumber";
dgvCreditList.Columns[3].HeaderText = "Description";
dgvCreditList.Columns[3].DataPropertyName = "CreditDescription";
dgvCreditList.Columns[4].HeaderText = "References / Cheque No";
dgvCreditList.Columns[4].DataPropertyName = "CreditReferencesCheque";
dgvCreditList.Columns[5].HeaderText = "Bank Name";
dgvCreditList.Columns[5].DataPropertyName = "CreditBankName";
dgvCreditList.Columns[6].HeaderText = "Date";
dgvCreditList.Columns[6].DataPropertyName = "CreditDate";
dgvCreditList.Columns[7].HeaderText = "Transaction Type";
dgvCreditList.Columns[7].DataPropertyName = "CreditTransactionType";
dgvCreditList.Columns[8].HeaderText = "Amount";
dgvCreditList.Columns[8].DataPropertyName = "CreditAmount";
dgvCreditList.Columns[0].Visible = false;
Connection.Close();
}
表2,代码2,数据网格2。
public void DataView()
{
Connection.Open();
MySqlCommand Command = new MySqlCommand("Select * From clientaccountcreditdebitdb", Connection);
DataTable dtdebit = new DataTable();
MySqlDataAdapter da = new MySqlDataAdapter(Command);
da.Fill(dtdebit);
dgvDebitList.DataSource = null;
dgvDebitList.AllowUserToAddRows = false;
dgvDebitList.AutoGenerateColumns = false;
dgvDebitList.ColumnCount = 9;
dgvDebitList.Columns[0].HeaderText = "id";
dgvDebitList.Columns[0].DataPropertyName = "ID";
dgvDebitList.Columns[1].HeaderText = "Account Name";
dgvDebitList.Columns[1].DataPropertyName = "DebitAccountName";
dgvDebitList.Columns[2].HeaderText = "Account Number";
dgvDebitList.Columns[2].DataPropertyName = "DebitAccountNumber";
dgvDebitList.Columns[3].HeaderText = "Description";
dgvDebitList.Columns[3].DataPropertyName = "DebitDescription";
dgvDebitList.Columns[4].HeaderText = "References / Cheque No";
dgvDebitList.Columns[4].DataPropertyName = "DebitReferencesCheque";
dgvDebitList.Columns[5].HeaderText = "Bank Name";
dgvDebitList.Columns[5].DataPropertyName = "DebitBankName";
dgvDebitList.Columns[6].HeaderText = "Date";
dgvDebitList.Columns[6].DataPropertyName = "DebitDate";
dgvDebitList.Columns[7].HeaderText = "Transaction Type";
dgvDebitList.Columns[7].DataPropertyName = "DebitTransactionType";
dgvDebitList.Columns[8].HeaderText = "Amount";
dgvDebitList.Columns[8].DataPropertyName = "DebitAmount";
dgvDebitList.Columns[0].Visible = false;
dgvDebitList.DataSource = dtdebit;
Connection.Close();
}
这是我的表格。
这里有什么问题吗?
暂无答案!
目前还没有任何答案,快来回答吧!