图书借阅管理中的问题

noreenxqc111 2017-12-27 11:16:42
如图我想根据图书名称中的内容搜索相对应Booklist表中的Book_Borrow的数据并加1,下面的代码,哪里有问题啊,应该怎么改啊




string str = "Data Source=LENOVO-PC\\MRWWK;Initial Catalog=Book;Persist Security Info=True;User ID=sa;Password=123456";
SqlConnection myConn = new SqlConnection(str);
myConn.Open();

string sqlStr = " insert into Bookborrow(Reader_Id,Reader_Name,Book_Name) values('" + txtReaderId.Text + "','" + txtReaderName.Text + "','" + txtBook.Text + "') ";
SqlCommand myCmd = new SqlCommand(sqlStr, myConn);
myCmd.ExecuteNonQuery();

string sqlStr1 = "select Book_Borrow from Booklist where Book_Id='" + txtBook.Text + "'";
SqlCommand select = new SqlCommand(sqlStr1, myConn);
select.ExecuteNonQuery();
string updateSql = "update Booklist set Book_Borrow=Book_Borrow+1 where Book_Id='" + txtBook + "'";
SqlCommand update = new SqlCommand(updateSql, myConn);
update.ExecuteNonQuery();
myConn.Close();
...全文
580 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
php_wsd 2018-01-02
  • 打赏
  • 举报
回复
Book_Borrow为字符型字段,不能直接+1,改成数字型字段吧

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧