表名是否在数据库中存在的问题,MSDN有错??-----很着急,请大家帮忙,在线等待
我的程序要检验一下在数据库中某个表是否存在
刚好在MSDN中有这么一段程序,我就直接试了试
Const NameNotInCollection = 3265
Public DB As Database
Private Function ExistsTableQuery(TName As String) As Boolean
Dim Test As String
On Error Resume Next
' See if the name is in the Tables collection:
Test = DB.TableDefs(TName).Name
If Err <> NameNotInCollection Then
ExistsTableQuery = True
' Reset the error variable:
Err = 0
' See if the name is in the Queries collection:
Test = DB.QueryDefs(TName$).Name
If Err <> NameNotInCollection Then
ExistsTableQuery = True
End If
End If
End Function
Private Sub Form_Load()
Set DB = DBEngine.Workspaces(0).OpenDatabase_("d:\company_admin\company_admin.mdb.mdb")
Debug.Print "BadTable "; IIf(ExistsTableQuery("sell"), _
"does", "doesn't"); " exist."
Debug.Print "Authors "; IIf(ExistsTableQuery("Authors"), _
"does", "doesn't"); " exist."
End Sub
里面的语句我基本上没改,只修改了OpenDatabase中的路径,编译时也没有报错,可是运行的时候窗口上什么也没有,这是怎么回事??难道MSDN有错吗??