nested query and dataset

N

nannu

Hi,

i am using the following query

string query = "SELECT *"+
"FROM DataSet"+
"WHERE Param_ID =(Select Data1 from testcases
where TestCaseID='TC001')
DataAdapter da=new DataAdapter();
mycommand = new OleDbCommand(query, mycon);
myds = new System.Data.DataSet();
da = new OleDbDataAdapter();
da.SelectCommand = mycommand;
===============PROBLEM================
//da.TableMappings.Add("Table", "testcases");
da.TableMappings.Add("Table", "DataSet");

if i add both the tables compiler gives error.
 
M

Marc Gravell

I doubt that the *compiler* would complain about that. The runtime might
throw an exception - firstly because you have duplicated the
table-name, and second because you only seem to be returning a single
grid of data...

Perhaps post the actual error text?

Marc
 
N

nologo

capture the error with
try
{
da.TableMappings.Add("Table", "DataSet");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
 
C

Cor Ligthert [MVP]

Nannu,

As Marc wrote already will your code forever only returning one row.

As you want to retrieve two resultsets in one fill, you need at least to map
table and table1 (or any tablename you start with your fill).

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top