我的存储过程如下所示:
Alter PROCEDURE [dbo].[productfilter_whatsnew]
@query1 nvarchar(max),
@query2 nvarchar(max),
@date date,
@pid varchar(5)
AS
select *
FROM Productcolorimage pci
where entry_date > @date
and selectproduct = @pid + ' ' + @query1
order by @'@query2'
GO
我的函数传递值
public DataTable productfilter_whatsnew(ProductBAL objbal)
{
DataTable dt = new DataTable();
using (SqlConnection conn = new SqlConnection(strconn))
{
conn.Open();
SqlCommand cmd = new SqlCommand("productfilter_whatsnew", conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter[] para = {
new SqlParameter("@query1","and colorid in('3')"),
new SqlParameter("@query2","pid ASC"),
new SqlParameter("@date","14-09-2013"),
new SqlParameter("@pid","1")
};
try
{
cmd.Parameters.AddRange(para);
SqlDataAdapter d = new SqlDataAdapter(cmd);
d.Fill(dt);
conn.Close();
}
catch (Exception ex)
{
throw ex;
}
}
return dt;
}
但是显示不同的放置错误@query1
和@query2
......