nested query and dataset

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • nannu

    nested query and dataset

    Hi,

    i am using the following query

    string query = "SELECT *"+
    "FROM DataSet"+
    "WHERE Param_ID =(Select Data1 from testcases
    where TestCaseID='TC0 01')
    DataAdapter da=new DataAdapter();
    mycommand = new OleDbCommand(qu ery, mycon);
    myds = new System.Data.Dat aSet();
    da = new OleDbDataAdapte r();
    da.SelectComman d = mycommand;
    =============== PROBLEM======== ========
    //da.TableMapping s.Add("Table", "testcases" );
    da.TableMapping s.Add("Table", "DataSet");

    if i add both the tables compiler gives error.
  • Marc Gravell

    #2
    Re: nested query and dataset

    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

    Comment

    • nologo

      #3
      Re: nested query and dataset

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

      Comment

      • Cor Ligthert [MVP]

        #4
        Re: nested query and dataset

        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

        "nannu" <namit24dec@gma il.comschreef in bericht
        news:d26ae166-210a-4821-8b4e-430114d9c239@s3 3g2000pri.googl egroups.com...
        Hi,
        >
        i am using the following query
        >
        string query = "SELECT *"+
        "FROM DataSet"+
        "WHERE Param_ID =(Select Data1 from testcases
        where TestCaseID='TC0 01')
        DataAdapter da=new DataAdapter();
        mycommand = new OleDbCommand(qu ery, mycon);
        myds = new System.Data.Dat aSet();
        da = new OleDbDataAdapte r();
        da.SelectComman d = mycommand;
        =============== PROBLEM======== ========
        //da.TableMapping s.Add("Table", "testcases" );
        da.TableMapping s.Add("Table", "DataSet");
        >
        if i add both the tables compiler gives error.

        Comment

        Working...