久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

使用ADO訪問(wèn)數(shù)據(jù)庫(kù)時(shí)怎樣判斷某一表名是否存在

 網(wǎng)絡(luò)摘記 2014-10-26

方法1:
    Dim adoConnectionX As New ADODB.Connection
    Dim adoSchemaRecordsetX As New ADODB.Recordset
    'Ms SQL 7:
    'adoConnectionX.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Data Source=yuer;DataBase=NorthwindCS"
    'Access 2000:
    adoConnectionX.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\DRptPlus\DRptPlus\Data\NWind2K.mdb;Persist Security Info=False"
    
    Dim TestTableName As String
    TestTableName = "產(chǎn)品"
    
    Set adoSchemaRecordsetX = adoConnectionX.OpenSchema(adSchemaTables, Array(Empty, Empty, TestTableName, "Table"))
    
    If Not adoSchemaRecordsetX.EOF Then
     MsgBox "[" & TestTableName & "]表已存在!"
    End If
    
    
    方法2(引用Microsoft ADO Extensions 2.1 for DDL and Security (ADOX)):
    (主持人注:需要升級(jí)至VB 6.0SP3)
    Dim adoConnectionX As New ADODB.Connection
    'Ms SQL 7:
    adoConnectionX.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Data Source=yuer;DataBase=NorthwindCS"
    'Access 2000:
    'adoConnectionX.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\DRptPlus\DRptPlus\Data\NWind2K.mdb;Persist Security Info=False"
    
    Dim adoxCatalogX As New ADOX.Catalog
    Set adoxCatalogX.ActiveConnection = adoConnectionX
    
    Dim TestTableName As String
    TestTableName = "產(chǎn)品"
    
    Dim adoxTableX As ADOX.Table
    For Each adoxTableX In adoxCatalogX.Tables
     If adoxTableX.Name = TestTableName Then
     MsgBox "[" & TestTableName & "]表已存在!"
     Exit For
     End If
    Next
    
    主持人注:方法2也可以這樣:
    Private Sub Command1_Click()
    Dim cat As ADOX.Catalog
    Dim tbl As ADOX.Table
    
    Set cat = New ADOX.Catalog
    Set cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.3.51;" _
    & "Data Source=C:\Program Files\Microsoft Visual Studio\VB98\Biblio.mdb"
    On Error Resume Next
    Set tbl = cat.Tables("MyTable")
    
    If tbl Is Nothing Then
     MsgBox "MyTable doesn't exist"
    Else
     MsgBox "MyTable exists"
     Set tbl = Nothing
    End If
    
    Set cat = Nothing
    Set con = Nothing
    End Sub

方法三:
select * from sysobjects where name='TblName'
    if rst.recordcount=0 then
     不存在此表
    else
     存在
    end if 

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,,所有內(nèi)容均由用戶發(fā)布,,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式,、誘導(dǎo)購(gòu)買(mǎi)等信息,,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,,請(qǐng)點(diǎn)擊一鍵舉報(bào),。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類(lèi)似文章 更多