Office中国论坛/Access中国论坛

标题: [分享]Excute 和 RunSql 的区别 [打印本页]

作者: andymark    时间: 2007-4-25 09:08
标题: [分享]Excute 和 RunSql 的区别
      Excute 和 RunSql 在ACCESS中都可以用来执行SQL语句,前者执行SQL语句不会出现提示,后者则需要借助DoCmd.SetWarnings False来关闭系统提示,除此之外,两者在书写语法上还是有小小区别

     RunSql下面2种书写方式都能执行:

    方法1:   

Sql = "INSERT INTO SupplyRate ( PartNumber )" _
     & " SELECT SupplierPartNum.PartNumer" _
     & " FROM SupplierPartNum" _
    & " WHERE SupplierPartNum.PartNumer Not In (select SupplyRate.PartNumber from SupplyRate) AND SupplierPartNum.Technology=[Forms]![FrmSupplyRate]![CmbTechnology]"

  方法2:

Sql = "INSERT INTO SupplyRate ( PartNumber )" _
     & " SELECT SupplierPartNum.PartNumer" _
     & " FROM SupplierPartNum" _
    & " WHERE SupplierPartNum.PartNumer Not In (select SupplyRate.PartNumber from SupplyRate) AND SupplierPartNum.Technology='" & [Forms]![FrmSupplyRate]![CmbTechnology] & "
'"


   而Execute只能采用后者


作者: eyewitnes    时间: 2007-4-25 17:31
谢谢分享~!留名备查
作者: fan0217    时间: 2007-4-25 20:59
采用ADO来执行SQL语句,还可以使用事务.
作者: 方漠    时间: 2007-4-26 01:18
学习了.谢谢!




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3