日期:2014-05-18 浏览次数:20787 次
#using System.Data #using System.Data.Sql //... SqlConnection conn = new SqlConnection([你的连接字符串]) conn.Open(); SqlCommand cmd = new SqlCommand("UPDATE books SET book_num=book_num-1 WHERE book_id=@book_id"); cmd.Parameters.Add("@book_id",SqlDbType.Int).Value=[你获取book_id] int ret = cmd.ExcuteNonQuery(); if(ret>0) ;//更改成功 else ;//更改失败,没有对应book_id //... conn.Close(); conn.Dispose();