Hi

In the following code, I get an Error when I try to Fill the Dataset

String sql = "SELECT * FROM Table1 UNION SELECT * FROM Table2 UNION SELECT * FROM Table3"
SqlDataAdapter earnAggAdapter = new SqlDataAdapter(sql, con)
earnAggAdapter.Fill(tempDS, "Earnings"); // I get a "System Error" her

If I try with only the Union of Table1 and Table2 it works
Does that mean that the DataAdapter does not support more than one Union in the same statement
Is there another way to make this work

thanks

Jane

Re: Problem with a DataAdapter - Newbie Question by Bernie

Bernie
Tue Feb 03 21:52:14 CST 2004

Hi Jane,

Try using parens around the unions:
sql = "SELECT * FROM Table1 UNION (SELECT * FROM Table2 UNION (SELECT * FROM
Table3"));

Also, are you sure the structure of all tables is precisely the same? Try
running the query in sql query analyzer.

HTH,

Bernie Yaeger

"Jane K." <anonymous@discussions.microsoft.com> wrote in message
news:F7793226-A021-467E-A7A3-0B8EC2088171@microsoft.com...
> Hi,
>
> In the following code, I get an Error when I try to Fill the Dataset:
>
>
> String sql = "SELECT * FROM Table1 UNION SELECT * FROM Table2 UNION SELECT
* FROM Table3";
> SqlDataAdapter earnAggAdapter = new SqlDataAdapter(sql, con);
> earnAggAdapter.Fill(tempDS, "Earnings"); // I get a "System Error" here
>
> If I try with only the Union of Table1 and Table2 it works.
> Does that mean that the DataAdapter does not support more than one Union
in the same statement?
> Is there another way to make this work?
>
> thanks!
>
> Jane