Hi everyone!
I have two search sql commands and I would like to get the result in one datagridview. How can i do this?
My search codes:
First -
private void button1_Click(object sender, EventArgs e)
{
try
{
string connStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;";
OleDbConnection conn = new OleDbConnection(connStr);
OleDbDataAdapter da = new OleDbDataAdapter("Select * from [" + testcb.SelectedItem.ToString() + "$] where [" + addcb.SelectedItem.ToString() + "] = '" + addtb.Text + "'", conn);
DataTable ds = new DataTable();
da.Fill(ds);
dataGridView2.DataSource = ds;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}Second -
private void searchbtn_Click(object sender, EventArgs e)
{
try
{
string connStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;";
OleDbConnection conn = new OleDbConnection(connStr);
OleDbDataAdapter da = new OleDbDataAdapter("Select * from [" + testcb.SelectedItem.ToString() + "$] where [" + comboBox1.SelectedItem.ToString() + "] = '" + textBox5.Text + "'", conn);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView2.DataSource = dt;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}I have one datagridview and would like to see total result of 2 requests in one(tables will be the same!)
Thanks a lot!
Sincerely,
Adil Aliyev