我使用的是:conn = new OleDbConnection(strconn);
conn.Open();
OleDbCommand cmd = new OleDbCommand(strcmd, conn);
cmd.ExecuteNonQuery();其中 如果 strcmd = "delete * from tableA";
执行起来没问题。可以遇到复杂的字符串,就抛出异常!比如:strcmd = "delete b from tableB as b 
inner join tableA as a on a.订单号 = b.订单号
where a.日期 between '2005-5-5' and '2007-7-7'"就会抛出异常,异常信息:"指定包含要删除的记录的表".

解决方案 »

  1.   

    delete * from tableB  where tableB.订单号 in (select 订单号 from tableB) And tableA.日期 between #'2005-5-5'# and #'2007-7-7'#
      

  2.   

    sorrydelete * from tableB  where tableB.订单号 in (select 订单号 from tableA) And tableA.日期 between #'2005-5-5'# and #'2007-7-7'#
      

  3.   

    sorry again :)delete * from tableB  where tableB.订单号 in (select 订单号 from tableA) And tableA.日期 between #2005-5-5# and #2007-7-7#
      

  4.   

    汗 我就不信我写不对
    delete * from tableB  where tableB.订单号 in (select 订单号 from tableA where tableA.日期 between #2005-5-5# and #2007-7-7#)
      

  5.   

    为什么它与我写的不一样?是一种变形么?那vb.net和vc是否都各自不同?
    这样sql的兼容性优势不就减弱了?
      

  6.   

    至于执行一句 sql  说白了 ADO.NET执行的原理都一样的,至于是SQL语句内部复杂不复杂 貌似根调用程序关系不大,另ADO与C#和VB貌似没有关系的
      

  7.   

    这是纯sql啊 和编程语言无关 ……
      

  8.   

    这是纯sql啊 和编程语言无关 ……那我写的不是纯sql么?