Я не могу заполнить данные в OleDbDataAdapter
Я получаю OleDbException
со следующим сообщением
Syntax error in FROM clause.
в этой строке adapter.Fill(dataset, "User")
Вот код
Imports System.Data.OleDb
Public Class Form1
Public connection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\MyDatabase.mdb;Persist Security Info=False")
Private Sub button_display_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button_display.Click
connection.Close()
connection.Open()
Dim adapter As New OleDbDataAdapter
adapter.SelectCommand = New OleDbCommand
adapter.SelectCommand.Connection = connection
adapter.SelectCommand.CommandText = "select * from user;"
Dim dataset As New DataSet
adapter.Fill(dataset, "User")
connection.Close()
Dim datarow = dataset.Tables("User").Rows(0)
Dim fname, lname As String
fname = datarow(0)
lname = datarow(1)
txtfirstname.Text = fname
txtlastname.Text = lname
End Sub
End Class
Я попытался заменить
Dim adapter As New OleDbDataAdapter
adapter.SelectCommand = New OleDbCommand
adapter.SelectCommand.Connection = connection
adapter.SelectCommand.CommandText = "select * from user;"
Dim dataset As New DataSet
adapter.Fill(dataset, "User")
с
Dim adapter As New OleDbDataAdapter("select * from user;", connection)
Dim dataset As New DataSet
adapter.Fill(dataset, "User")
а также я пробовал
Dim adapter As New OleDbDataAdapter
adapter.SelectCommand = New OleDbCommand("select * from user;", connection)
Dim dataset As New DataSet
adapter.Fill(dataset)
Но я получаю то же исключение Syntax error in FROM clause