|
检查数据库表是否存在函数 |
来源:转载 人气:1861 录入时间:2007-11-8 |
1.
function existTab(TabName as string) as boolean
dim TR as new recordset
dim Adoconn as new adodb.connection
adoconn.open connstr
existtab=true
on error goto Err1
tr.open "select from testtable"
tr.close
adoconn.close
exit function
Err1:
adoconn.close
existtab=false
end function
2.
Function IsExist(tb As String) As Boolean
Dim adoRst As New ADODB.Recordset
Dim adoConn As New ADODB.connection
Dim strConn As String
Dim sql As String
strConn = "driver={SQL server};server=lyb;uid=sa;pwd=;database=jppoem"
adoConn.Open strConn
sql = "select * from sysobjects where id=object_id('" + tb + "')"
adoRst.Open sql, adoConn, 3, 3
If adoRst.EOF Then
IsExist = False
Else
IsExist = True
End If
End Function
|
|
|