T
Tony Johansson
Hello!
I have a DataGridView called dgv
These tables customers and Orders below is from the Northwind database.
When I run this small applications nothing is displayed in the DataGridView.
Does anybody have any reason for this behaviour.
Even if I comment out these three rows just below the DataGridView is still
empty
SqlDataAdapter orderAdapter = new SqlDataAdapter("Select * from Orders",
thisConnection);
orderAdapter.Fill(thisDataSet, "Orders");
DataRelation custOrderRel = thisDataSet.Relations.Add("CustOrders",
thisDataSet.Tables["Customers"].Columns["CustomerID"],
thisDataSet.Tables["Orders"].Columns["CustomerID"]);
public Form1()
{
InitializeComponent();
SqlConnection thisConnection = new SqlConnection();
thisConnection.ConnectionString = "Integrated Security=true;" +
"Initial Catalog=Northwind;" +
"Data Source=hempc\\SQLExpress";
DataSet thisDataSet = new DataSet();
SqlDataAdapter custAdapter = new SqlDataAdapter ("Select * from
customers", thisConnection);
custAdapter.Fill(thisDataSet, "Customers");
SqlDataAdapter orderAdapter = new SqlDataAdapter("Select * from
Orders", thisConnection);
orderAdapter.Fill(thisDataSet, "Orders");
DataRelation custOrderRel =
thisDataSet.Relations.Add("CustOrders",
thisDataSet.Tables["Customers"].Columns["CustomerID"],
thisDataSet.Tables["Orders"].Columns["CustomerID"]);
dgv.DataSource = thisDataSet;
}
//Tony
I have a DataGridView called dgv
These tables customers and Orders below is from the Northwind database.
When I run this small applications nothing is displayed in the DataGridView.
Does anybody have any reason for this behaviour.
Even if I comment out these three rows just below the DataGridView is still
empty
SqlDataAdapter orderAdapter = new SqlDataAdapter("Select * from Orders",
thisConnection);
orderAdapter.Fill(thisDataSet, "Orders");
DataRelation custOrderRel = thisDataSet.Relations.Add("CustOrders",
thisDataSet.Tables["Customers"].Columns["CustomerID"],
thisDataSet.Tables["Orders"].Columns["CustomerID"]);
public Form1()
{
InitializeComponent();
SqlConnection thisConnection = new SqlConnection();
thisConnection.ConnectionString = "Integrated Security=true;" +
"Initial Catalog=Northwind;" +
"Data Source=hempc\\SQLExpress";
DataSet thisDataSet = new DataSet();
SqlDataAdapter custAdapter = new SqlDataAdapter ("Select * from
customers", thisConnection);
custAdapter.Fill(thisDataSet, "Customers");
SqlDataAdapter orderAdapter = new SqlDataAdapter("Select * from
Orders", thisConnection);
orderAdapter.Fill(thisDataSet, "Orders");
DataRelation custOrderRel =
thisDataSet.Relations.Add("CustOrders",
thisDataSet.Tables["Customers"].Columns["CustomerID"],
thisDataSet.Tables["Orders"].Columns["CustomerID"]);
dgv.DataSource = thisDataSet;
}
//Tony