スキーマ情報(全テーブル名または全列名)の取得方法を記載します。
スキーマ情報を取得する
Dim builder As SqlConnectionStringBuilder = New SqlConnectionStringBuilder() builder.DataSource = ".\SQLEXPRESS" builder.AttachDBFilename = "D:\DB\TestDB.mdf" builder.IntegratedSecurity = True builder.UserInstance = True builder.MultipleActiveResultSets = True Dim ConnectString As String = builder.ToString() Using sqlConnect As New SqlConnection(ConnectString) sqlConnect.Open() '全てのテーブルを取得します。 Dim schemaTable As DataTable = sqlConnect.GetSchema("Tables") Dim command As SqlCommand = sqlConnect.CreateCommand() command.CommandText = "SELECT * FROM Table_1" Dim dtReader As SqlDataReader = command.ExecuteReader() 'テーブル内の列情報を取得します。 schemaTable = dtReader.GetSchemaTable() dtReader.Close() End Using