[英]SQL Server parameter query fails to return results
I have an application in which I had to change the selection of a day be a range of days instead. 我有一个应用程序,其中我不得不将一天的选择更改为几天范围。 The query when ran in Management Studio works and returns the correct results. 该查询在Management Studio中运行时有效,并返回正确的结果。 However in the application nothing is returned. 但是,在应用程序中什么也不会返回。
Code: 码:
SqlCommand com = new SqlCommand();
com.Connection = Program.ConnnectDatabase();
com.CommandText = Resources.FillProcessing;
string strDay = string.Empty;
if (cboProcessDay.Text.ToString().Trim() == "Monday")
strDay = "'Monday'";
com.Parameters.Add(new SqlParameter("@Day", strDay));
DataTable dt = new DataTable();
SqlDataAdapter adt = new SqlDataAdapter();
adt.SelectCommand = com;
adt.Fill(dt);
SQL: SQL:
SELECT data.*
FROM Rec_data data, acc_info info
WHERE Day IN (@Day)
AND info.foracid = data.foracid
Any idea what i am doing wrong? 知道我在做什么错吗?
我建议使用SQL事件探查器来跟踪实际上是从c#运行的语句。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.