我的内联SQL查询就像这样
DataSet ds = SqlHelper.ExecuteDataset(GlobalSettings.DbDSN, CommandType.Text,
"SELECT TOP 1000 [ID],[Project],[Owner],[Consultant],[Contractor],[Value],
[Level1], [Level2] ,[Status] ,[Category] ,[Country],[CreatedDate],
[CreatedByID], [CreatedByName]
FROM [DBname].[dbo].[tbl_Projects]
where [Category] like %@Category%
and Value=1000
and Country like'%Bahrain%'
order by CreatedDate",
new SqlParameter("@Category","oil") );
一切看起来都没问题。但是它会抛出错误
System.Data.SqlClient.SqlException: Incorrect syntax near 'Category'.
我相信使用类似查询时我做错了。 任何人都可以指出出了什么问题吗?
答案 0 :(得分:2)