can i write somthing like this:
cmd = new OleDbCommand("select * from cmn_mst; select * from cmn_typ", oledbCon);
But this is showing an error. Is there any other way to write multiple select in dataset?
write a stored procedure, that outputs 2 ref cursors and call it in your .net code.
a detailed answer would need a knowledge in the type of provider your using.
But this should help google stuff.
This article might help.
You can't do that in one OleDbCommand, you need to split the queries in two commands, so 2 datasets..
new OleDbCommand("sp_cmn_mst", oledbCon); and sp_cm_mst is a storeprocedure returning 2 table.. then the dataset is containing 2 table data...Method 1
Try making this in two commands.
DataSet set1 = new DataSet();
using(OleDbDataAdapter adapter = new OleDbDataAdapter("select * from cmn_mst;", connection))
{
adapter.Fill(set1);
}
DataSet set2 = new DataSet();
using(OleDbDataAdapter adapter = new OleDbDataAdapter("select * from cmn_typ;", connection))
{
adapter.Fill(set2);
}
After Returning Two Dataset You can merge it into once
set1.EnforceConstraints = false;
set1.Merge(set2, true, MissingSchemaAction.AddWithKey);
set1.EnforceConstraints = true;
set1.AcceptChanges();
For further reference:
Method 2: