Nothing is displayed in the DataGridView


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
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top