DataSet ds;
DataRow dr;
string newsid;
void Page_Load(Object sender, EventArgs e)
{
SqlConnection MyConnection;
string ConnStr, strCon;
newsid = Request.Params["id"];
MyConnection = new SqlConnection("server=ADMIN-PC;database=news;uid=sa;pwd='123456'");
MyConnection.Open();
string strCom = "Select biaoti,zhaizi,neirong,img,counter,shijian from news where id=" + newsid;
ds = new DataSet();
SqlDataAdapter myCommand = new SqlDataAdapter(strCom, MyConnection);
myCommand.Fill(ds, "news");
dr = ds.Tables["news"].Rows[0];
strCon = "Select counter from news where id=" + newsid;
SqlCommand mycommand2 = new SqlCommand(strCon, MyConnection);
SqlDataReader reader = mycommand2.ExecuteReader();
reader.Read();
int i = reader.GetInt32(0);
i++;
reader.Close();
strCon = "Update news set counter=" + i.ToString() + "where (id=" + newsid + ")";
mycommand2.CommandText = strCon;
mycommand2.ExecuteNonQuery();
MyConnection.Close();
}
阿波罗的战车
蝴蝶不菲
相关分类