Given conn
is an OdbcConnection
object and count
is an int
, how would I use count as parameter for my query?
...
var query = conn.CreateCommand();
query.CommandText = "select top ? * from players order by Points desc";
query.Parameters.Add("top", OdbcType.Int).Value = count;
var reader = query.ExecuteReader();
while (reader.Read())
{
...
}
...
This way I get a syntax error ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '@P1'.
If it is not possible the way I tried how would I do it the correct way instead?