asp.net中一个bottun按钮可以执行两个事件
点击借阅按钮后可以将textbox中的数据传给数据表Booklist,这一代码我已实现。我还想根据图书Id中textbox的值,查找到相应的Sum,并且加1.这一代码怎么...
点击 借阅按钮后可以将textbox中的数据传给数据表Booklist,这一代码我已实现。我还想根据图书Id中textbox的值,查找到相应的Sum,并且加1.这一代码怎么加进去啊....求大神解答
protected void btnBorrow_Click(object sender, EventArgs e)
{
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();
myConn.Close();
这个代码应该加到哪里啊:
string updateSql = "update Booklist set Book_Borrow=Book_Borrow+1 where Book_Id='" +txtSum + "'"; } 展开
protected void btnBorrow_Click(object sender, EventArgs e)
{
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();
myConn.Close();
这个代码应该加到哪里啊:
string updateSql = "update Booklist set Book_Borrow=Book_Borrow+1 where Book_Id='" +txtSum + "'"; } 展开
1个回答
展开全部
protected void btnBorrow_Click(object sender, EventArgs e)
{
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 updateSql = "update Booklist set Book_Borrow=Book_Borrow+1 where Book_Id='" +txtSum + "'"; }
myCmd.CommendText = updateSql;
myCmd.ExecuteNonQuery();
myConn.Close();
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询