This is the code from one class:
Private Sub LoadTable()
dt.Dispose()
command.CommandText = "SELECT * FROM @TableName"
command.Parameters.Add(New MySqlParameter("TableName", TableName))
dt = SQL.ExecuteCommand(command)
command.Dispose()
End Sub
This is the code from another class, which the above code calls:
Public Function ExecuteCommand(ByVal Command As MySqlCommand)
Dim dt As New DataTable
Dim da As New MySqlDataAdapter
Dim con As New MySqlConnection
con.ConnectionString = GetConnectionString
Command.Connection = con
con.Open()
da.SelectCommand = Command
da.Fill(dt)
con.Close()
con.Dispose()
da.Dispose()
Return dt
End Function
The variable TableName is equal to the string Client.
The syntax is valid, as I have tried it both in the MySQL Workbench and it works if I try it unparametrized.
The error I'm getting is that the syntax is not valid: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''Client'' at line 1".
Any clue how to fix this, while still using a parametrized MySqlCommand?