Hi,
I am rewriting a VB6 application in VB2010. The program needs to work with a third party database (Access 97). It seems that certain table names are 'reserved' and cannot be accessed by VB2010, though it works perfectly in VB6. I reduced the problem to the following code. The database 'TestDb.mdb' used has 5 identical, empty tables.
The following combined message is produced:
The table Table is not accepted: De component FROM bevat een syntaxisfout.
The table Index is not accepted: De component FROM bevat een syntaxisfout.
The table Schema is not accepted: De component FROM bevat een syntaxisfout.
The table Schem is accepted!
The table Tabel is accepted!
The table NonExisting is not accepted: De Microsoft Jet-database-engine kan de invoertabel of -query NonExisting niet vinden. Zorg ervoor dat deze bestaat en dat de naam correct is gespeld.
Why can't all these tables be accessed????
I am rewriting a VB6 application in VB2010. The program needs to work with a third party database (Access 97). It seems that certain table names are 'reserved' and cannot be accessed by VB2010, though it works perfectly in VB6. I reduced the problem to the following code. The database 'TestDb.mdb' used has 5 identical, empty tables.
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dbTest As New OleDb.OleDbConnection
Dim TableName(5) As String
TableName(0) = "Table"
TableName(1) = "Index"
TableName(2) = "Schema"
TableName(3) = "Schem"
TableName(4) = "Tabel"
TableName(5) = "NonExisting"
Dim Message As String = ""
dbTest.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = TestDb.mdb"
dbTest.Open()
For N = 0 To 5
Dim da = New OleDb.OleDbDataAdapter("SELECT * FROM " & TableName(N), dbTest)
Dim ds As New DataSet
Try
da.Fill(ds, TableName(N))
Message = Message & "The table " & TableName(N) & " is accepted!" & vbCr
Catch ex As Exception
Message = Message & "The table " & TableName(N) & " is not accepted: " & ex.Message & vbCr
End Try
Next
MsgBox(Message)
End
End Sub
The following combined message is produced:
The table Table is not accepted: De component FROM bevat een syntaxisfout.
The table Index is not accepted: De component FROM bevat een syntaxisfout.
The table Schema is not accepted: De component FROM bevat een syntaxisfout.
The table Schem is accepted!
The table Tabel is accepted!
The table NonExisting is not accepted: De Microsoft Jet-database-engine kan de invoertabel of -query NonExisting niet vinden. Zorg ervoor dat deze bestaat en dat de naam correct is gespeld.
Why can't all these tables be accessed????