Community discussion forum

Join Datasets

Tags: ado.net, db India
  • 3 months 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

    nitin.manipal@gmail.com

  • Advertisement

    Simply the fastest line-level profiler for .NET ever

    “The low overhead means it has minimal impact on the execution of my program”
    Mark Everest, Development Team Leader, Renault F1 Team Ltd.

    Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now

  • 3 months 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

  • 3 months 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).