'is there a way to show 'order table and customer table' to one dataGridView?
private void button3_Click(object sender, EventArgs e)
{
Stack<Customer> customer = new Stack<Customer>();
Stack<Order> orders = new Stack<Order>();
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=.\SQLExpress;Initial Catalog=Northwind;Integrated Security=true";
if (con.State == ConnectionState.Closed)
{
con.Open();
SqlCommand cmd = new SqlCommand("select Top 5 ContactName,Freight from Orders,Customers WHERE Orders.CustomerID=Customers.CustomerID ORDER BY Freight DESC;", con);
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Customer c = new Customer();
c.ContactName = (string)reader["ContactName"];
Order o = new Order();
o.Freight = (decimal)reader["Freight"];
orders.Push(o);
customer.Push(c);
}
con.Close();
}
dataGridView3.DataSource = customer.ToList();
dataGridView4.DataSource = orders.ToList();
}
I'm trying to get top 5 users name and detail using Stack but I can't show both orders and customer table to one datagridview
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
