我正在尝试使用以下代码从 db 中选择数据:
getForecastsCommand.CommandText = @"SELECT TOP @Count * FROM Forecasts Order by [ForecastId] DESC";
var countParam = getForecastsCommand.CreateParameter();
countParam.ParameterName = "@Count";
countParam.Value = count;
countParam.DbType = DbType.Int32;
getForecastsCommand.Parameters.Add(countParam);
但它不起作用:
Incorrect syntax near '@Count'.
为什么它不起作用?