i am trying to bind a datagridview from these two queries select * from customers;select * from employee but i want to bind only first two column from customer and first two coloumn from employee
but only the first two coloumn of customer are getting binded and first two coloumn of employees are not getting binded
her is the code can someone tell me my mistake where am i foing wrong
MySqlConnection con = new MySqlConnection(@"server=localhost;User Id=root;database=classicmodels");
con.Open();
MySqlDataAdapter adp = new MySqlDataAdapter("select * from customers;select * from employee;" ,con);
DataSet ds = new DataSet();
adp.Fill(ds);
DataTable dt = new DataTable();
DataRow dr = null;
DataColumn id = new DataColumn("id", typeof(Int32));
dt.Columns.Add(id);
DataColumn firstname = new DataColumn("Firstname", typeof(String));
dt.Columns.Add(firstname);
DataColumn customerNumber = new DataColumn("customerNumber", typeof(Int32));
dt.Columns.Add(customerNumber);
DataColumn customerName = new DataColumn("customerName", typeof(String));
dt.Columns.Add(customerName);
// DataRow dr1 = null;
for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
{
dr = dt.NewRow();
dr[id] = ds.Tables[0].Rows[i].ItemArray[0];
dr[firstname] = ds.Tables[0].Rows[i].ItemArray[1];
dt.Rows.Add(dr);
}
DataRow dr1 = null;
for (int j = 0; j <= ds.Tables[1].Rows.Count - 1; j++)
{
dr1 = dt.NewRow();
dr1[customerNumber] = ds.Tables[1].Rows[j].ItemArray[0];
dr1[customerName] = ds.Tables[1].Rows[j].ItemArray[1];
dt.Rows.Add(dr1);
}
dataGridView1.DataSource = dt;