Imports dao
Imports System.Data.OleDb
Private Sub Get_Access_Fields_Description()
'------------------------
Dim dbs As dao.Database
Dim tdf As dao.TableDef
Dim dbe As New dao.DBEngine
Dim Field_Name As String
Dim Field_Type As String
Dim Field_Length As String
Dim Field_Description As String
Dim Field_AllowZeroLength As String
Dim sDbPath$
Dim sDbPassword$
sDbPath$ = gDataBase_Name
sDbPassword$ = "Password"
dbs = dbe.OpenDatabase(sDbPath$, False, False, "MS Access;PWD=" & sDbPassword$ & ";")
On Error Resume Next
For Each tdf In dbs.TableDefs
MsgBox("Tabell: " & tdf.Name)
Dim Doc_OleDb_DataAdapter As New OleDbDataAdapter("SELECT * FROM " & tdf.Name, Connection_String)
Dim Doc_DataSet As New DataSet
Doc_OleDb_DataAdapter.Fill(Doc_DataSet)
For Each Column As System.Data.DataColumn In Doc_DataSet.Tables(0).Columns
Field_Name = Column.ColumnName
Field_Type = Column.DataType.ToString
'Field_Name = dbs.TableDefs(tdf.Name).Fields(Column.ColumnName).Name.ToString
'Field_Type = dbs.TableDefs(tdf.Name).Fields(Column.ColumnName).Type.ToString
Select Case Field_Type
Case "System.Int32"
Field_Type = "Långt heltal"
Case "System.String"
Field_Type = "Text"
Case "System.Double"
Field_Type = "Dubbel"
Case "System.Boolean"
Field_Type = "Ja/Nej"
End Select
Field_Length = dbs.TableDefs(tdf.Name).Fields(Column.ColumnName).Size.ToString
Field_Description = dbs.TableDefs(tdf.Name).Fields(Column.ColumnName).Properties("Description").Value.ToString
Field_AllowZeroLength = dbs.TableDefs(tdf.Name).Fields(Column.ColumnName).AllowZeroLength
If dbs.TableDefs(tdf.Name).Fields(Column.ColumnName).AllowZeroLength Then
Field_AllowZeroLength = "Ja"
Else
Field_AllowZeroLength = "Nej"
End If
MsgBox("Fält: " & Field_Name & " Typ: " & Field_Type & " Längd: " & Field_Length & " Beskrivning: " & Field_Description & " Tillåt nollängd: " & Field_AllowZeroLength)
Field_Name = ""
Field_Type = ""
Field_Length = ""
Field_Description = ""
Field_AllowZeroLength = ""
Next
Next tdf
dbs.Close()
dbs = Nothing
tdf = Nothing
'------------------------
End Sub