Dim adoConnection As ADODB.Connection
Dim rs As ADODB.Recordset
Set adoConnection = New ADODB.Connection
Dim xDate As StringxDate = Format(Date, "yyyymmdd")
adoConnection.ConnectionString = "driver={SQL Server};" & _
"server=dcser;uid=sa;pwd=;database=stxt"
adoConnection.Open
Set rs = adoConnection.Execute("drop table rs" + CStr(xDate) + "")
Set rs = adoConnection.Execute("select * into rs" + CStr(xDate) + " from rs order by name")
怎么在这段中加入判断 表有没有存在,如果有存在就出现对话框问是否删除呢??

解决方案 »

  1.   

    啊,容易啊,,俺给你一个例子吧!!
    [email protected]
      

  2.   

    http://expert.csdn.net/Expert/topic/2619/2619006.xml?temp=.9452936
      

  3.   

    SELECT name FROM sysobjects WHERE (xtype = 'u' and name='表名')
      

  4.   

    adoConnection.Open
    Set rs = adoConnection.Execute("select name from sysobjects where xtype='u' and name='rs" + CStr(xDate) + "'")
    If rs.EOF = True Then
    MsgBox "Not This Table"
    Set rs = adoConnection.Execute("select * into rs" + CStr(xDate) + " from rs order by name")
    Else
    Set rs = adoConnection.Execute("drop table rs" + CStr(xDate) + "")End If