1.连接数据库
Dim Conn As OleDb.OleDbConnection
Conn = New System.Data.OleDb.OleDbConnection"Data Source=.\SQLEXPRESS;AttachDbFilename=c:\你的数据库名.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")
2.读取数据库中的全部表名
Conn.Open()
Dim Table As Data.DataTable = Data.DataTable = Conn.GetSchema("Tables")
Dim drc As System.Data.DataRowCollection = Table.Rows
Dim dr As Data.DataRow = Nothing
For Each dr In drc
Dim tablename As String = dr("TABLE_NAME").ToString '读取数据库中全部表名
if tablename = "你的数据表名" Then
Return tablename
End if
Next
Conn.Close()
Return ""
供你参考