1.绑定 GridView 控件
SqlDataAdapter cmd = new SqlDataAdapter("select id,title,inputdate from Article where id in (select articleid from Ct_Class where classid like '" + classID + "') and (isValidate = 1) order by InputDate desc,px desc", con);
DataSet ds = new DataSet();
cmd.Fill(ds, "Article");
//GridView1.DataSource = ds.Tables["Article"].DefaultView;
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
2.信息提取,用于末级
SqlCommand cmd = new SqlCommand("SELECT Title,Content,inputDate,Original FROM Article WHERE ID='"+ ID+ "'",con);
SqlDataReader dataReader = cmd.ExecuteReader();
if (dataReader.Read())
{
lblTitle.Text=dataReader["Title"].ToString();
//lblContent.Text=dataReader["content"].ToString();
lblDate.Text=dataReader["inputdate"].ToString();
lblSourse.Text=dataReader.GetString(3).ToString();
Labcontent.Text = dataReader.GetString(1).ToString();
}
3.更新操作
SqlCommand cmdupdate = new SqlCommand();
cmdupdate.Connection = con;
cmdupdate.CommandText = "update V_vote set vcount=vcount+1 where id='" + this.dcradio.SelectedValue.ToString() + "'";
cmdupdate.ExecuteNonQuery();