what's wrong?

  • Thread starter Thread starter Hrvoje Voda
  • Start date Start date
H

Hrvoje Voda

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

listFunctions.DisplayMember = "Name";

nGroupID = (Guid[])

new ArrayList( listGroupID.Items ).ToArray(typeof(Guid));

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

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

{


DataRow[] FGrows = userDb.dataSetAccounts.FunctionsGroups.Select(

sSelect,"FunctionID",System.Data.DataViewRowState.CurrentRows);


foreach (DataSetAccounts.FunctionsGroupsRow row in FGrows)

{

DataSetAccounts.FunctionsRow function =

userDb.dataSetAccounts.Functions.FindByFunctionID( row.FunctionID );

if ( function != null )

{


if(listFunctions.Items.ToString () == function.Name)

listFunctions.SetItemChecked(i, true);

}

}

}



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

Why?



Hrcko
 
Hi Hrvoje,

nGroupID = (Guid[])new ArrayList( listGroupID.Items ).ToArray(typeof(Guid));

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


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

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





listFunctions.DisplayMember = "Name";
nGroupID = (Guid[])
new ArrayList( listGroupID.Items ).ToArray(typeof(Guid));
sSelect = "GroupID ='" + nGroupID.ToString () + "'";
for (int i=1; i<listFunctions.Items.Count ; i++)
{
DataRow[] FGrows = userDb.dataSetAccounts.FunctionsGroups.Select(
sSelect,"FunctionID",System.Data.DataViewRowState.CurrentRows);
foreach (DataSetAccounts.FunctionsGroupsRow row in FGrows)
{
DataSetAccounts.FunctionsRow function =
userDb.dataSetAccounts.Functions.FindByFunctionID( row.FunctionID );
if ( function != null )
{
if(listFunctions.Items.ToString () == function.Name)
listFunctions.SetItemChecked(i, true);
}
}
}
 
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
 
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'.
 
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.
 
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 ...
 
Back
Top