A
Avery Scott
Hi all,
I am very new to ADO.NET (have to use version 1.1) and database
programming in general so please forgive me if my questions appear to be
naive. That being said, here is my problem ...
I have a database with some tables and relations between them. I try to
fill a DataSet with those tables *and* their relations by using a
SqlDataAdapter. My code looks like this:
public DataSet GetDataSet(string tablename, SqlConnection sqlConn)
{
DataSet ds = new DataSet();
SqlDataAdapter adapter = new SqpDataAdapter();
adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
adapter.SelectCommand = new SqlCommand("select * from " + tablename, sqlConn);
adapter.Fill(ds, tablename);
return ds;
}
What I get is one table. What I really want is the table and the tables
that are related to this one by their foreign keys so that I can follow
its relations. Ideally my DataSet contains all this but I neither know how
to formulate the right SQL query nor how to utilize the ADO.NET API to
accomplish this. I would be grateful if someone could sketch a solution to
this problem--thanks in advance.
Regards,
Avery Scott.
I am very new to ADO.NET (have to use version 1.1) and database
programming in general so please forgive me if my questions appear to be
naive. That being said, here is my problem ...
I have a database with some tables and relations between them. I try to
fill a DataSet with those tables *and* their relations by using a
SqlDataAdapter. My code looks like this:
public DataSet GetDataSet(string tablename, SqlConnection sqlConn)
{
DataSet ds = new DataSet();
SqlDataAdapter adapter = new SqpDataAdapter();
adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
adapter.SelectCommand = new SqlCommand("select * from " + tablename, sqlConn);
adapter.Fill(ds, tablename);
return ds;
}
What I get is one table. What I really want is the table and the tables
that are related to this one by their foreign keys so that I can follow
its relations. Ideally my DataSet contains all this but I neither know how
to formulate the right SQL query nor how to utilize the ADO.NET API to
accomplish this. I would be grateful if someone could sketch a solution to
this problem--thanks in advance.
Regards,
Avery Scott.