建立一个临时表select a,b,c,d into #temp1 from  table1
查找数据  select  a,c from #temp1清空临时表  drop table #temp1这样的语句,我在VB里怎么调用?当我点command1时这3条语句自动执行啊我只知道
rs.open“”这样可以做到吗?

解决方案 »

  1.   

    可以用Connection对象实现如:
    Dim mOutPutConn     As ADODB.Connection
    Set mOutPutConn = New ADODB.Connection
    mOutPutConn.Open "连接字符串"strSQL = "select  a,c from #temp1"
    mInputConn.Execute strSQL
    strSQL = "drop table #temp1"
    mInputConn.Execute strSQL
      

  2.   

    dim cn as new adodb.connection
    dim rs as new adodb.recordsetcn.open "<连接字符串>"  '根据数据库情况写cn.execute "select a,b,c,d into #temp1 from  table1"rs.open "select  a,c from #temp1",cn
    ......rs.close
    set rs = nothing
    cn.execute "drop table #temp1"cn.close
    set cn = nothing