Date: 05/28/10 (Asp Dot Net) Keywords: sql Hi everybody!
String q1 =
"SELECT c.customerName, r.orderId, r.orderName "+
"FROM customers AS c, orders as r "+
"WHERE (c.ustomerId = r.customerId) ";
String[] q = new String[] { q1 };
DataSet d = getDataSet(q);
DataTable t = d.Tables[0];
for (int i=0; i < t.Rows.Count; i++) {
String s = t.Rows[i]["customerName"] + ", " +
t.Rows[i]["orderId"] + ", " + t.Rows[i]["orderName"] + ".";
Console.WriteLine(s);
}
This part is clear for me. Then, I want to achieve the same result by using DataRelation. In this case I should write something like this:
String[] q = new String[] {
"SELECT customerId, customerName FROM customers",
"SELECT orderId, customerId, orderName FROM orders"
};
DataSet d = getDataSet(q);
d.Relations.Add(new DataRelation("customer2order",
d.Tables[0].Columns["customerId"],
d.Tables[1].Columns["customerId"]));
How to print out the combined data as I did that in first example?
|