IF EXISTS (select * from tempdb.dbo.sysobjects where id=object_id('tempdb.dbo.#tmp')) 
BEGIN 
drop table #tmp 
create table #tmp (id int, worker_card varchar(4), pos_card varchar(4), start_time datetime, end_time datetime, now_date datetime,interval_time int, rt_id int, area_id int)
END
怎么上边的语句在查询分析器ok,而在vb中不ok,为什么啊
请问vb中如何执行上列sql语句啊,rs.open sql,cn,1,1 不可以吗?谢谢了^_^

解决方案 »

  1.   


    function IsTmpTableExist(byref conn,strTableName)
       dim rstSchema   set rstSchema=conn.OpenSchema(adSchemaTables)   'adSchemaTables=20
       rstSchema.Filter="Table_Name='tempdb.dbo.#tmp'"
       if rstSchema.eof or rstSchema.bof then
           IsTmpTableExist=False
       else
           IsTmpTableExist=True
       end if
    end function
      

  2.   

    一個事件
    如果是在存儲過程中怎是整個存儲過程的執行期間
    如果是在VB中 比如我這種方法
    就是在BeginTrans和CommitTrans之間
        Dim con As New ADODB.Connection
        con.ConnectionString = Me.Adodc1.ConnectionString
        con.BeginTrans
        con.Execute "Create #t..."
        con.Execute "...."
        con.CommitTrans
        con.Close