Passer le nom de la table en paramètre dans une requète
Bonjour
Comment passer le nom de la table en paramètre ?
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| Public Sub Getlist(ByVal tablename As String)
Dim command As New OleDbCommand
Dim recordset As OleDbDataReader
recordset = Nothing
command.Connection = Connection
command.CommandText = "SELECT field1 FROM dic2 ;"
' dic2 est le nom de la table et j'essaye à la place de dic2 de passer tablename
'j'ai tenté ainsi
command.CommandText = "SELECT palabra FROM [table?] ;"
command.Parameters.Add("table?", OleDbType.VarChar).Value = tablename
' une erreur ne trouve pas la table
recordset = command.ExecuteReader()
While recordset.Read
listout.Add(recordset.GetValue(0).ToString)
End While
End Sub |
Merci