codegooglecom / easyasp

Automatically exported from code.google.com/p/easyasp
0 stars 0 forks source link

Easp.db.Exec 执行SQL语句,执行成功、失败都返回0 #48

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
我使用Easp.db.Exec 执行SQL语句,无论执行成功、失败都返回0。

我的语句:
Set rs = Easp.db.Exec("Delete From [ZW] a Where a.ZWID ="&ZWID&" And not 
exists (select top 1 ZWMC from [User] b where b.ZWID=a.ZWID)")

使用这个语句的要求是:删除[ZW]表a.ZWID 
="&ZWID前判断是否已经在[User]表中使用,已经
使用,不删除,否则删除!
我的语句能够达到我的要求,但怎么得到“如果是执行SQL语��
�,执行成功返回1,执行失败返回
0”呢?是我用错了吗?

Original issue reported on code.google.com by yiye.c...@gmail.com on 17 Oct 2009 at 2:20

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
执行之前写Easp.db.dbConn=Conn

Original comment by wja...@gmail.com on 19 Oct 2009 at 8:31

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
有的,执行之前写Easp.db.dbConn=Conn,
不然怎么执行删除的?

而我的语句:执行删除是成功的!

Original comment by yiye.c...@gmail.com on 21 Oct 2009 at 2:19

GoogleCodeExporter commented 9 years ago
返回值是不用 Set 的。
直接 输出 就好。

Original comment by Tainray@gmail.com on 21 Oct 2009 at 2:53

GoogleCodeExporter commented 9 years ago
是这样吗?
rs = Easp.db.Exec("Delete From [ZW] a Where a.ZWID ="&ZWID&" And not 
exists (select top 1 ZWMC from [User] b where b.ZWID=a.ZWID)")

如果是的话,无论执行成功、失败,都返回rs的值为1 。

Original comment by yiye.c...@gmail.com on 21 Oct 2009 at 3:48

GoogleCodeExporter commented 9 years ago
rs = Easp.db.Exec("Delete From [ZW] a Where a.ZWID ="&ZWID)

经测试,以上语句执行成功返回1,执行失败返回0 。

rs = Easp.db.Exec("Delete From [ZW] a Where a.ZWID ="&ZWID&" And not 
exists (select top 1 ZWMC from [User] b where b.ZWID=a.ZWID)")
无论执行成功、失败,都返回rs的值为1 。

Set rs = Easp.db.Exec("Delete From [ZW] a Where a.ZWID ="&ZWID&" And not 
exists (select top 1 ZWMC from [User] b where b.ZWID=a.ZWID)")

无论执行成功、失败都返回0。

Original comment by yiye.c...@gmail.com on 21 Oct 2009 at 4:04

GoogleCodeExporter commented 9 years ago
执行成功是指语句正确被执行,而不是指有数据被删除才叫��
�行成功噢,这一点你要区分开。
执行失败的意思是这句SQL有问题,不能被正确执行。

Original comment by Tainray@gmail.com on 23 Oct 2009 at 1:48

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
哦!是我误解了!谢谢!

那我想对“数据删除”成功与否进行判断,要怎么做?

Original comment by yiye.c...@gmail.com on 26 Oct 2009 at 1:47