B
Ben
I am having a problem with a web service I've created getting an "
Index was outside the bounds of the array." when I try to get the
value of ET.TerritoryName below. I've verified the length of ET is
4 after reallocating the dynamic array and the error happens when i =
0 so the first iteration of the loop. Does anyone have any idea what
the problem is? I know it's something simple I'm just not seeing.
EventTotalDS[] ET = null;
cnn.Open();
SqlCommand cmd = new SqlCommand("BP_SREventTotals", cnn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@p_ContactGUID", SqlDbType.UniqueIdentifier).Value
= ContactGUID;
SqlDataAdapter oDA = new SqlDataAdapter(cmd);
DataSet oDS = new DataSet();
oDA.Fill(oDS,"EventTotals");
ET = new EventTotalDS[oDS.Tables["EventTotals"].Rows.Count + 1];
int i = 0;
foreach(DataRow dtRow in oDS.Tables["EventTotals"].Rows)
{
ET.TerritoryName = dtRow["TerritoryName"].ToString();
//above line gets index error on the left hand side
i++;
}
Index was outside the bounds of the array." when I try to get the
value of ET.TerritoryName below. I've verified the length of ET is
4 after reallocating the dynamic array and the error happens when i =
0 so the first iteration of the loop. Does anyone have any idea what
the problem is? I know it's something simple I'm just not seeing.
EventTotalDS[] ET = null;
cnn.Open();
SqlCommand cmd = new SqlCommand("BP_SREventTotals", cnn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@p_ContactGUID", SqlDbType.UniqueIdentifier).Value
= ContactGUID;
SqlDataAdapter oDA = new SqlDataAdapter(cmd);
DataSet oDS = new DataSet();
oDA.Fill(oDS,"EventTotals");
ET = new EventTotalDS[oDS.Tables["EventTotals"].Rows.Count + 1];
int i = 0;
foreach(DataRow dtRow in oDS.Tables["EventTotals"].Rows)
{
ET.TerritoryName = dtRow["TerritoryName"].ToString();
//above line gets index error on the left hand side
i++;
}