what's wrong?

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

    #1

    what's wrong?

    Can someone please tell me what is wrong with this code ?

    listFunctions.D isplayMember = "Name";

    nGroupID = (Guid[])

    new ArrayList( listGroupID.Ite ms ).ToArray(typeo f(Guid));

    sSelect = "GroupID ='" + nGroupID.ToStri ng () + "'";

    for (int i=1; i<listFunctions .Items.Count ; i++)

    {


    DataRow[] FGrows = userDb.dataSetA ccounts.Functio nsGroups.Select (

    sSelect,"Functi onID",System.Da ta.DataViewRowS tate.CurrentRow s);


    foreach (DataSetAccount s.FunctionsGrou psRow row in FGrows)

    {

    DataSetAccounts .FunctionsRow function =

    userDb.dataSetA ccounts.Functio ns.FindByFuncti onID( row.FunctionID );

    if ( function != null )

    {


    if(listFunction s.Items[i].ToString () == function.Name)

    listFunctions.S etItemChecked(i , true);

    }

    }

    }



    In listGroupID I have one item of GroupID but in array FRows I get 0!

    Why?



    Hrcko


  • Morten Wennevik

    #2
    Re: what's wrong?

    Hi Hrvoje,

    nGroupID = (Guid[])new ArrayList( listGroupID.Ite ms ).ToArray(typeo f(Guid));

    sSelect = "GroupID ='" + nGroupID.ToStri ng () + "'";


    nGroupID is an array of type Guid[], I believe your sSelect should be something like

    sSelect = "GroupID ='" + nGroupID[0].ToString () + "'";





    On Thu, 19 May 2005 16:44:15 +0200, Hrvoje Voda <hrvoje.voda@lu atech.com> wrote:
    [color=blue]
    > listFunctions.D isplayMember = "Name";
    >nGroupID = (Guid[])
    > new ArrayList( listGroupID.Ite ms ).ToArray(typeo f(Guid));
    >sSelect = "GroupID ='" + nGroupID.ToStri ng () + "'";
    >for (int i=1; i<listFunctions .Items.Count ; i++)
    >{
    >DataRow[] FGrows = userDb.dataSetA ccounts.Functio nsGroups.Select (
    >sSelect,"Funct ionID",System.D ata.DataViewRow State.CurrentRo ws);
    >foreach (DataSetAccount s.FunctionsGrou psRow row in FGrows)
    >{
    >DataSetAccount s.FunctionsRow function =
    >userDb.dataSet Accounts.Functi ons.FindByFunct ionID( row.FunctionID );
    >if ( function != null )
    >{
    > if(listFunction s.Items[i].ToString () == function.Name)
    > listFunctions.S etItemChecked(i , true);
    >}
    >}
    >}[/color]



    --
    Happy coding!
    Morten Wennevik [C# MVP]

    Comment

    • Hrvoje Voda

      #3
      Re: what's wrong?

      This works, but somehow in nGroupID array list when I do the select
      statement one ID is missing.

      At the begining I have a lenght = 2 but in select it's on 1




      *** Sent via Developersdex http://www.developersdex.com ***

      Comment

      • Morten Wennevik

        #4
        Re: what's wrong?

        Can't help you there as I don't know what is in the database. Nor am I sure what you mean by 'in the beginning'.


        On Fri, 20 May 2005 10:46:20 +0200, Hrvoje Voda <hrcko@net4u.hr > wrote:
        [color=blue]
        > This works, but somehow in nGroupID array list when I do the select
        > statement one ID is missing.
        >
        > At the begining I have a lenght = 2 but in select it's on 1
        >
        >
        >
        >
        > *** Sent via Developersdex http://www.developersdex.com ***
        >[/color]



        --
        Happy coding!
        Morten Wennevik [C# MVP]

        Comment

        • Hrvoje Voda

          #5
          Re: what's wrong?

          in table FunctionsGroups I have 4 GroupID and 4 FunctionID.

          3 GroupID are the same, but forth is the one that I don't get in FGrows
          Array.





          *** Sent via Developersdex http://www.developersdex.com ***

          Comment

          • Morten Wennevik

            #6
            Re: what's wrong?

            Well, your select statement retrieves only those GroupID that are identical to the first one in nGroupID, which would be the first one in listGroupID.

            You might want to repost your question in a new thread. Please provide as much detail as you can, like code, what you get, what you wanted to get, what you aren't getting ...


            On Fri, 20 May 2005 12:55:21 +0200, Hrvoje Voda <hrcko@net4u.hr > wrote:
            [color=blue]
            > in table FunctionsGroups I have 4 GroupID and 4 FunctionID.
            >
            > 3 GroupID are the same, but forth is the one that I don't get in FGrows
            > Array.
            >
            >
            >
            >
            >
            > *** Sent via Developersdex http://www.developersdex.com ***
            >[/color]



            --
            Happy coding!
            Morten Wennevik [C# MVP]

            Comment

            Working...