V
VB Novice Hendri
Guest
Hope you can help.
I need to use a Variable instead of a Table Name "Eiergeregte" in this line of code. There is 36 or so Table Names that has to be represented by the Variable. Simply swoping it with the Variable does not work.
Dim cmdText As String = "SELECT ID, RecipeName, Comment FROM Eiergeregte"
Below is the Code Block this Line is used in.
TitleListBox.Items.Clear()
Dim ConnectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=M:\My Documents\My Resepte\Hoofgeregte.accdb;"
Using cn As OleDbConnection = New OleDbConnection(ConnectionString)
cn.Open()
Dim cmdText As String = "SELECT ID, RecipeName, Comment FROM Eiergeregte"
Using cmd As OleDbCommand = New OleDbCommand(cmdText, cn)
Dim reader = cmd.ExecuteReader()
While reader.Read()
TitleListBox.Items.Add(reader("RecipeName"))
recipesLst.Add(New Recipe With {
.ID = Convert.ToInt32(reader("ID")),
.RecipeName = reader("RecipeName").ToString(),
.Comment = reader("Comment").ToString()
})
End While
End Using
End Using
Continue reading...
I need to use a Variable instead of a Table Name "Eiergeregte" in this line of code. There is 36 or so Table Names that has to be represented by the Variable. Simply swoping it with the Variable does not work.
Dim cmdText As String = "SELECT ID, RecipeName, Comment FROM Eiergeregte"
Below is the Code Block this Line is used in.
TitleListBox.Items.Clear()
Dim ConnectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=M:\My Documents\My Resepte\Hoofgeregte.accdb;"
Using cn As OleDbConnection = New OleDbConnection(ConnectionString)
cn.Open()
Dim cmdText As String = "SELECT ID, RecipeName, Comment FROM Eiergeregte"
Using cmd As OleDbCommand = New OleDbCommand(cmdText, cn)
Dim reader = cmd.ExecuteReader()
While reader.Read()
TitleListBox.Items.Add(reader("RecipeName"))
recipesLst.Add(New Recipe With {
.ID = Convert.ToInt32(reader("ID")),
.RecipeName = reader("RecipeName").ToString(),
.Comment = reader("Comment").ToString()
})
End While
End Using
End Using
Continue reading...