"SELECT sum(Preference) FROM [projectDB].[dbo].[Vote] group by preference;
SqlDataReader
ArrayList myArr =newArrayList();
when i read the data in the values i get are
10,14,10,17
sum(Prefernece) to the arraylist, it will not allow me.
while (dreader.Read())
{
myArr.Add(datareader["sum(Preference)"].ToString());
if(myArr.? > 15)
{
Response.Write("Its greater than 15");
}
}
sorry,
think i posted this into the wrong section...its not really an sql problem.
but if anyone has any ideas they will be appriciated
|||ArrayList uses index to get the specific position's value. Because you use reader() to get the data, you have to add extra steps to do. Here is the clue
int position = 0;
while (dreader.Read())
{
myArr.Add(datareader["sum(Preference)"].ToString());
if((int)myArr[position] > 15)
{
Response.Write("Its greater than 15");
}
position++;
}
Hope it helps
sql
No comments:
Post a Comment