{
InitializeComponent();
SqlConnection cnt = new SqlConnection(GetConnectionString());
cnt.Open();
SqlCommand cmd = cnt.CreateCommand();
cmd.CommandText = “select * from Orders; select * from [Order Details]”;
northwind.Load( cmd.ExecuteReader(), LoadOption.OverwriteChanges, “Orders”,”Order Details”);
cnt.Close();
}
static private string GetConnectionString()
{
// To avoid storing the connection string in your code,
// you can retrieve it from a configuration file, using the
// System.Configuration.ConfigurationSettings.AppSettings property
return “Data Source=(local);Initial Catalog=Northwind;”
+ “Integrated Security=SSPI;”;
}
private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e)
{
string s = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
orderDetailsBindingSource.Filter = “OrderId=” + s;
}