i am trying to count the no of time a value appears in a column for a given event ID. i have written the following code:
private
void TotalChanged(){
///<summary>
///this procedure calculates the total amount of times the event has been
///modified altogether. the number is read only and written to a text box.
///</summary>int evID = Convert.ToInt32(Request["EID"]);
myda =new SqlDataAdapter("SELECT COUNT (TotalChanged) FROM EventDateChange WHERE EventID = '" + evID + "'", mycn);
myda.Fill(ds3, "ChangedEvent");
foreach (DataRow drin ds3.Tables[0].Rows)
{
int evTotal = (int)dr["TotalChanged"];
Txt_Changes.Text = evTotal.ToString();
}
}
i know the queries ok, as i tested it in SQl Query analyser, but how do i write that value to the textbox called text-changes? everytime i run it i get the errorColumn 'TotalChanged' does not belong to table ChangedEvent.??
Anyone any ideas?? Thanks in advance!
TrySELECT COUNT (TotalChanged)AS TotalChanged FROM EventDateChange WHERE EventID = '" + evID + "'",
This is because when you use COUNT(), there is no column name. After you add AS TotalChanged, you assign the column name to the count.
|||Doh!! Thanks! Works perfectly![Big Smile [:D]](http://pics.10026.com/?src=/emoticons/emotion-2.gif)
No comments:
Post a Comment