V
VB Novice Hendri
Guest
I am using code from Xingyu Zhao it seems simple enuf but I got one more problem.
I keep getting an error "Additional infomation: Syntax error in FROM clouse. on this line "Dim reader = cmd.ExecuteReader()" I got no clue what this is about.
Private connString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=M:\My Documents\My Resepte\MainDishes.accdb"
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Using myConn As OleDbConnection = New OleDbConnection(connString)
myConn.Open()
Dim dtNames As DataTable = myConn.GetSchema("Tables", New String() {Nothing, Nothing, Nothing, "TABLE"})
ListBox1.Items.Clear()
For Each row As DataRow In dtNames.Rows
Dim tablename As String = CStr(row(2))
ListBox1.Items.Add(tablename)
Next
End Using
End Sub
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
Dim tableName As String = ListBox1.SelectedItem.ToString()
Using myConn As OleDbConnection = New OleDbConnection(connString)
myConn.Open()
Dim cmdText As String = "SELECT * FROM {Main Dishes}"
Using cmd As OleDbCommand = New OleDbCommand(cmdText, myConn)
Dim reader = cmd.ExecuteReader()
While reader.Read()
TextBox1.Text = reader("ID").ToString()
TextBox2.Text = reader("Recipe Name").ToString()
TextBox3.Text = reader("Caption").ToString()
TextBox4.Text = reader("Delivery").ToString()
TextBox5.Text = reader("Con1").ToString()
TextBox6.Text = reader("Con2").ToString()
TextBox7.Text = reader("Con3").ToString()
End While
End Using
End Using
End Sub
Continue reading...
I keep getting an error "Additional infomation: Syntax error in FROM clouse. on this line "Dim reader = cmd.ExecuteReader()" I got no clue what this is about.
Private connString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=M:\My Documents\My Resepte\MainDishes.accdb"
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Using myConn As OleDbConnection = New OleDbConnection(connString)
myConn.Open()
Dim dtNames As DataTable = myConn.GetSchema("Tables", New String() {Nothing, Nothing, Nothing, "TABLE"})
ListBox1.Items.Clear()
For Each row As DataRow In dtNames.Rows
Dim tablename As String = CStr(row(2))
ListBox1.Items.Add(tablename)
Next
End Using
End Sub
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
Dim tableName As String = ListBox1.SelectedItem.ToString()
Using myConn As OleDbConnection = New OleDbConnection(connString)
myConn.Open()
Dim cmdText As String = "SELECT * FROM {Main Dishes}"
Using cmd As OleDbCommand = New OleDbCommand(cmdText, myConn)
Dim reader = cmd.ExecuteReader()
While reader.Read()
TextBox1.Text = reader("ID").ToString()
TextBox2.Text = reader("Recipe Name").ToString()
TextBox3.Text = reader("Caption").ToString()
TextBox4.Text = reader("Delivery").ToString()
TextBox5.Text = reader("Con1").ToString()
TextBox6.Text = reader("Con2").ToString()
TextBox7.Text = reader("Con3").ToString()
End While
End Using
End Using
End Sub
Continue reading...