I want to get a list of values, After I get one value I pass the value and call the same method.
if the structure is like
60
|
61
|
63
|
64
the code works fine and returns all the value when I pass 60.
but when the structure is like
60
| |
61 63
|
62
so here the parent id of 61 and 63 is 60.
Then the Org id passed after the first execution is 63, since 61 and 63 are read at the same time and 63 is the last read orgid, so it passes 63 to the next loop and it returns 0 and the loop end. therefore no execution is done using orgid 61. so 62 is missed. what mistake am I doing here. when a reader is reading 2 values in the same query then the second value read is passed. I want to pass all the value read in the query.
private DataSet BindGridView(int id, List<int> userids)
{
string GetOrgIDs = "select OrganisationID from tbl_organisation where ParentID =@ParentID";
MySqlParameter[] paramet = new MySqlParameter[1];
paramet[0] = new MySqlParameter("@ParentID", MySqlDbType.Int32);
paramet[0].Value = id;
int Orgid = 0;
MySqlDataReader reader = server.ExecuteReader(CommandType.Text, GetOrgIDs, paramet);
while (reader.Read())
{
Orgid = Convert.ToInt32(reader["OrganisationID"]);
userids.Add(Orgid);
}
reader.Close();
if (Orgid != 0)
{
BindGridView(Orgid, userids);
}
}
I call the method from page load
List<int> OrgIDs = new List<int>();
OrgIDs.Add(60);
BindGridView(60, OrgIDs);
I am using Mysql db