本帖最后由 goolean 于 2013-03-11 20:17:47 编辑

解决方案 »

  1.   

    我知道用“upate table2 set t2id=t2id+1 where t1id=(selet t1id from table1 where myid=参数);delete from table1 where myid=参数 ”同时执行两条语句也能实现 ,
    但我主要是想知道,如何分成两步,得到我想到的数据后,再执行第二条语句 。
      

  2.   

    如果不考虑性能,你也可以分几步啊
    cmb.CommandText="selet t1id from table1 where myid=参数";
    object t1id=cmb.ExecuteScalar();
    if(tlid!=null && tlid!=System.DBNull.Value) //先查出tlid
    {
       cmb.CommandText="delete from table1 where myid=参数";
    cmb.ExecuteNonquery();
       cmb.CommandText="upate table2 set t2id=t2id+1 where t1id=" + t1id.ToString();
    cmb.ExecuteNonquery();}
      

  3.   

    谢谢楼上,不好意思,我例子举的过于简单了,是这样,我参数过来后,想先得到 table1中的所有字段
    也就是读取各字段的内容,比如,table1中的title,mess,用于别处,也就是说,肯定有多个open(),close()的操作,然后,再去执行下一步的操作,不一定是删除,也许是根据 table1中的某个字段,去查询table2中的详情
      

  4.   

    获取记录集DataSet,然后在DataSet里找你要的信息