执行sql语句的问题!求救!!!

silvering 2008-06-12 11:23:21
需要执行3条sql语句,但是除了第一条执行成功外,第二条yjsl我想+1,结果确是成了+2,第三条语句更强,没有执行。
将三个语句在查询管理器中执行后,没有任何问题,哪位高手知道是怎么回事?

             
string sqlStr1,sqlStr2,sqlStr3;
sqlStr1 = "update TBL_BookInfoMX set state='1',ReaderID='" + this.ReaderID + "',JCCS=JCCS+1 WHERE BookID='" + BookID + "'";
sqlStr2 = "update TBL_ReaderInfo set yjsl=yjsl+1 where ReaderID='" + this.ReaderID + "'";
sqlStr3 = "INSERT INTO TBL_BookBorrow VALUES ('"+this.ReaderID+"','"+BookID+"',Getdate(),null,0)";


DataBase DB = new DataBase();

SqlConnection conn = DB.getDbConnection();

try
{
conn.Open();

SqlCommand cmd1 = new SqlCommand(sqlStr1, conn);

cmd1.ExecuteNonQuery();

//将TBL_ReaderInfo中的YJSL+1

SqlCommand cmd2 = new SqlCommand(sqlStr2, conn);

cmd2.ExecuteNonQuery();

//将记录插入TBL_BookBorrow中

SqlCommand cmd3 = new SqlCommand(sqlStr2, conn);

cmd3.ExecuteNonQuery();

}
finally
{
conn.Close();
}
return true;



...全文
100 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
whb147 2008-06-12
  • 打赏
  • 举报
回复
我靠
考验我们的眼力??
silvering 2008-06-12
  • 打赏
  • 举报
回复
难怪第二句总加2,第三句不执行的...

晕死了!
silvering 2008-06-12
  • 打赏
  • 举报
回复
......

我的错....


对不住大家了!
我姓区不姓区 2008-06-12
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 wzy_love_sly 的回复:]
太粗心了 :)
[/Quote]
wzy_love_sly 2008-06-12
  • 打赏
  • 举报
回复
太粗心了 :)
wzy_love_sly 2008-06-12
  • 打赏
  • 举报
回复
SqlCommand cmd2 = new SqlCommand(sqlStr2, conn);

cmd2.ExecuteNonQuery();

//将记录插入TBL_BookBorrow中

SqlCommand cmd3 = new SqlCommand(sqlStr2, conn);

2个sqlStr2
silvering 2008-06-12
  • 打赏
  • 举报
回复
太怪了

111,120

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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