首頁 >資料庫 >mysql教程 >不用ADOX也可以判断access表是否存在

不用ADOX也可以判断access表是否存在

WBOY
WBOY原創
2016-06-07 15:43:331464瀏覽

哈哈, 不用 ADOX也 可以 !! % Dim cn ,strCnn,rstSchema set cn = server.createobject("ADODB.Connection") set strCnn = server.createobject("ADODB.Recordset") set rstSchema = server.createobject("ADODB.Recordset") strCnn = "Provider=Microsof

哈哈,不用ADOX也可以!!
 

Dim cn ,strCnn,rstSchema

set cn = server.createobject("ADODB.Connection")   
set strCnn = server.createobject("ADODB.Recordset")
set rstSchema = server.createobject("ADODB.Recordset")

strCnn = "Provider=Microsoft.Jet.OLEDB.4.0;"
strCnn = strCnn & "Data Source=F:/asptest/tree.MDB;"
strCnn = strCnn & "Persist Security Info=False"

cn.Open strCnn
 
set rstSchema=cn.openSchema(20)
rstSchema.movefirst
Do Until rstSchema.EOF
  if rstSchema("TABLE_TYPE")="TABLE" then
      response.write rstSchema("TABLE_NAME") & "
"   
  end if
  rstSchema.movenext
Loop
cn.close

'set rstSchema = nothing
'set cn = nothing
 %>

SQL -->系统表sysobjects

access---》用ADOX的 例子:

Dim cn ,strCnn

set cn = server.createobject("ADODB.Connection")   
set strCnn = server.createobject("ADODB.Recordset")
 

strCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:/asptest/tree.MDB;Persist Security Info=False"

cn.Open strCnn
 Set tb = Server.CreateObject("ADOX.Table")
 Set cat = Server.CreateObject("ADOX.Catalog")
 Set cat.ActiveConnection = cn
 
 For Each a In cat.Tables
  Response.Write a.Name & "
"
 Next
 
cn.close
 %>
 

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn