Excellent post! You included a sample project plus a sample database :) Just one more thing -- when you paste code on Daniweb please use code tags:
[code=csharp]
....code here....
[/code]
I can't get the project to run though :( Locking up on the connection. Anyway I think I see the problem:
private void Form3_Load(object sender, EventArgs e)
{
//{!}string connectionstring="Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\hospdb.mdf;Integrated Security=True;Connect Timeout=5;User Instance=True";
//{!}SqlConnection con=new SqlConnection(connectionstring);
//{!}DataSet ds=new DataSet();
//{!}string command="SELECT Name,Address,Phone,Branch,Class FROM hosptab WHERE (Branch = 'SKIN')";
//{!}SqlDataAdapter da=new SqlDataAdapter(command,con);
//{!}da.Fill(ds,"hospital");
//{!}DataTable dt=ds.Tables["hospital"];
//da.Fill(hospdbDataSet, "hospital");
//{!}con.Open();
// TODO: This line of code loads data into the 'hospdbDataSet.hosptab' table. You can move, or remove it, as needed.
this.hosptabTableAdapter.Fill(this.hospdbDataSet.hosptab);
//{!}con.ResetStatistics();
//{!}con.Close();
//{!}con.Dispose();
}
That is the only line of the code really doing work to populate the DataSet. Your grid is bound to the typed DataSet. What you need to do is go to your TableAdapter on the DataSet designer, right click on it, and "Add Select Query". You should be able to define another Fill() method, ie FillSkin(), that will run your second query. You would then replace this line:
this.hosptabTableAdapter.Fill(this.hospdbDataSet.hosptab);
With:
this.hosptabTableAdapter.FillSkin(this.hospdbDataSet.hosptab);