我想使用此代碼來選擇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