数据库操作的问题
public SqlDataReader selectlendrtnrec(string readerid, string bookid)//查询是否这位读者借阅了这本图书
{
string cmdtext = "select * from lendrtnrec where readerid= " + " ' " + readerid + " ' " + "and bookid= " + " ' " + bookid + " ' ";
SqlCommand mycommand = new SqlCommand(cmdtext, myconn);
myconn.Open();
SqlDataReader dr = mycommand.ExecuteReader(CommandBehavior.CloseConnection);
return dr;
}
public int returnbook(string readerid, string bookid)//归还图书,操作lendrtnrec,readerinfo,bookinfo三个表
{
string cmdtext1 = "delete lendrtnrec where readerid= " + " ' " + readerid + " ' " + "and bookid= " + " ' " + bookid + " ' ";
string cmdtext2= "update readerinfo set 借书总数 =借书总数-1,未还书数=未还书数-1 where 编号= "+ " ' "+readerid + " ' ";
string cmdtext3 = "update bookinfo set 数量=数量+1 where 图书编号= " + " ' " + bookid + " ' ";
myconn.Open ();
SqlCommand mycommand1 = new SqlCommand(cmdtext1, myconn);
SqlCommand mycommand2 = new SqlCommand(cmdtext2, myconn);
SqlCommand mycommand3 = new SqlCommand(cmdtext3, myconn);
mycommand2.ExecuteNonQuery();
mycommand3.ExecuteNonQuery();
int nresult = mycommand1.ExecuteNonQuery();
&nbs