0
我正在合併兩個數據集,我希望重複的行只綁定一次,我該如何實現?將數據集中的重複行綁定一次
protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
showRelatedcat();
DataSet ds = new DataSet();
DataSet ds_frd = new DataSet();
String frdQuery = my query
String newquery = my other query
String queryString = another one
try
{
// Connect to the database and run the query.
SqlConnection connection = new SqlConnection(connectionString);
SqlDataAdapter adapter = new SqlDataAdapter(newquery, connection);
SqlDataAdapter adapter1 = new SqlDataAdapter(frdQuery, connection);
// Fill the DataSet.
adapter1.Fill(ds_frd);
adapter.Fill(ds);
ds.Merge(ds_frd, true);
connection.Close();
}
catch (Exception ex)
{
// The connection failed. Display an error message.
//Message.Text = "Unable to connect to the database.";
}
RadGrid1.DataSource = ds.Tables[0].;
}
這兩個查詢都有一些共同的行。
做兩個數據集只包含一個表合併數據集? – Narendra 2012-07-28 11:16:36
難道你不能只重構frdQuery + newquery到單個查詢並讓數據庫處理distinct()。似乎對我更有效率? – Pleun 2012-07-28 11:44:07