Join table?

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

    #1

    Join table?

    Hi,

    My sql join two table, how to call the fill method? thanks.

    string sqlStr = "select * from table1, table2";

    SqlDataAdapter myCommand = new SqlDataAdapter( sqlStr, myConnection);D ataSet
    ds = new DataSet();

    myCommand.Fill( ds, ?);


  • Carlson Quick

    #2
    Re: Join table?

    If I recall correctly, your "?" can be any string, which will represent the
    table created from the merge ( BTW a join is something else again ) of the
    two tables. So if for example you had
    Table1:
    integer
    1
    2
    3
    4
    and Table 2:
    integer2
    5
    6
    7
    8

    and you called myCommand.Fill( ds, "mergedTabl e" );

    you would have the following table inside the dataset ds

    ds.Tables["mergedTabl e"]
    integer integer2
    ------------------
    1 | 5
    2 | 6
    3. | 7
    4 | 8

    Of course I haven't worked with the Data Provider in a while but this is
    what I would expect to occur.
    "LL" <lionelluo@hotm ail.com> wrote in message
    news:uGg$6AOmDH A.1084@tk2msftn gp13.phx.gbl...[color=blue]
    > Hi,
    >
    > My sql join two table, how to call the fill method? thanks.
    >
    > string sqlStr = "select * from table1, table2";
    >
    > SqlDataAdapter myCommand = new SqlDataAdapter( sqlStr,[/color]
    myConnection);D ataSet[color=blue]
    > ds = new DataSet();
    >
    > myCommand.Fill( ds, ?);
    >
    >[/color]


    Comment

    Working...