Q: Putting the Information from a SQL Query into a DataGridView What would be the best way to display the results of this SQL statement:
select "WorkOrder"."WorkOrderID", "Customer"."FirstName", "Vehicles"."Model", "WorkOrder"."State" 
from "WorkOrder", "Customer", "Vehicles"
WHERE "WorkOrder"."VIN" = "Vehicles"."VIN" 
  AND "Vehicles"."CustomerID" = "Customer"."CustomerID"
  AND "WorkOrder"."State" = 'In Progress';

I am using C# WinForms with Visual Studio 2010. I can't quite seem to figure out how to put it in a DataGridView or something similar. Is there any way to do or cheat it into a DataGridView?

A: Easiest way would be put in a DataTable and assing it to .DataSource property like;
string command = @"select "WorkOrder"."WorkOrderID", "Customer"."FirstName", "Vehicles"."Model", "WorkOrder"."State"  from "WorkOrder", "Customer", "Vehicles" WHERE "WorkOrder"."VIN" = "Vehicles"."VIN" AND "Vehicles"."CustomerID" = "Customer"."CustomerID" AND "WorkOrder"."State" = 'In Progress'";

using(SqlConnection conn = new SqlConnection(connectionString))
using(SqlCommand command = conn.CreateCommand())
{
    command.Connection = conn;
    using(SqlDataAdapter adapter = new SqlDataAdapter())
    {
        adapter.SelectCommand = command;
        DataTable table = new DataTable();
        adapter.Fill(table);
        DataGridview1.DataSource = table;
        DataGridview1.AutoGenerateColumns = true;
    }
}

