我想使用此代码来选择DB数据:添加参数命令ADO.NET
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'.
为什么不是工作?
您应该在您正在使用的数据库上添加备注。 – Fionnuala 2012-07-20 11:29:50