Join Datasets

db India
  • 12 years ago

    Hi All,

     My problem i want to implement below mentiion query using Datasets. but dont know how to join different tables using Datasets. i could nut understand how to implement Datarelations here.

     Can anybody help me regarding this.

    QUERY -->

    strSql =
    string.Format (

    "update tblTrains tr " +

    "set tr.LOADEDTITAN = (select max(c.mtp_titan_nbr) as Loaded_MTP " +

    "from tblTrains t,train.cor_train_leg_dn@cor c " +

    "where t.archiveddt is null and " +

     

    "trim(t.TRAINNAME) = trim(c.train_leg_nm) " +

    "and tr.TRAINID = t.TRAINID " +

    "and c.train_kind_cd {1} " +

    "and (mtp_train_state_cd <> 'X'" +

    " or mtp_train_state_cd is null)), " +

    "tr.MTTITAN = (select max(c.mtp_titan_nbr) as MT_MTP " +

    "from tblTrains t,train.cor_train_leg_dn@cor c " +

    "where t.archiveddt is null and " +

    "T.MTTRAINNAME is not null and " +

    "trim(T.MTTRAINNAME) = trim(c.train_leg_nm) " +

    "and tr.TRAINID = t.TRAINID " +

    "and c.train_kind_cd {1} " +

    "and (mtp_train_state_cd <> 'X'" +

    " or mtp_train_state_cd is null)), " +

    "tr.ALIASTITAN = (select max(c.mtp_titan_nbr) as ALIAS_MTP " +

    "from tblTrains t,train.cor_train_leg_dn@cor c " +

    "where archiveddt is null " +

    "and trim(T.ALIASTRAINNAME) = trim(c.train_leg_nm) " +

    "and t.ALIASTRAINNAME is not null " +

    "and tr.TRAINID = t.TRAINID " +

    "and c.train_kind_cd {1} " +

    "and (mtp_train_state_cd <> 'X'" +

    " or mtp_train_state_cd is null)), " +

    "tr.ALIASLOADEDTITAN = (select max(c.mtp_titan_nbr) as ALIAS_Loaded_Titan " +

    "from tblTrains t,train.cor_train_leg_dn@cor c " +

    "where archiveddt is null " +

    "and trim(T.ALIASLOADEDTRAINNAME) = trim(c.train_leg_nm) " +

    "and t.ALIASLOADEDTRAINNAME is not null " +

    "and tr.TRAINID = t.TRAINID " +

    "and c.train_kind_cd {1} " +

    "and (mtp_train_state_cd <> 'X'" +

    " or mtp_train_state_cd is null)), " +

    "tr.ALIASEMPTYTITAN = (select max(c.mtp_titan_nbr) as ALIAS_EMPTY_Titan " +

    "from tblTrains t,train.cor_train_leg_dn@cor c " +

    "where archiveddt is null " +

    "and trim(T.ALIASEMPTYTRAINNAME) = trim(c.train_leg_nm) " +

    "and t.ALIASEMPTYTRAINNAME is not null " +

    "and tr.TRAINID = t.TRAINID " +

    "and c.train_kind_cd {1} " +

    "and (mtp_train_state_cd <> 'X'" +

    " or mtp_train_state_cd is null)) " +

    "where tr.archiveddt is null " +

    "and tr.Lineupid = {0}",mLineup.LineupID,sqlTrainKindCD);

     

    Regards,

    Nitin Aggarwal

    +91-9886604958

    [email protected]

  • 12 years ago

    Hi,

    Requirement is:

    1) there are 2 databases. we need to Update data in table A in Database 1 from ( joined Resultset of TABLE A of Database 1 and TABLE B of Database 2.
    2) the JOIN has to be done INMEMORY using ADO.NET Datasets.
    3) Data is Huge in both the tables.

    Any suggestion will be helpful,

    Nitin Aggarwal

  • 12 years ago

    I rather ask. You cannot make whole operation at database level? Using Left Join or similar syntax? I guess if you use one dataset with two tables inside, you can perform this operation with Join syntax also above this dataset.

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“I invented the term Object-Oriented, and I can tell you I did not have C++ in mind.” - Alan Kay