我有一个循环,我在其中获取某些 ID 以在数据库中进行调用。查询中有 2 个变量。
第一个工作正常,但第二个没有返回任何内容。我已经对其进行了大量测试,并且知道正确的值正在传递给查询。不确定我在这里做错了什么。我用我知道正在返回的硬编码值替换变量,它工作正常。
这是我的代码:
SqlDataAdapter d8;
d8 = new SqlDataAdapter("SELECT SUM(CAST(AMOUNT AS BIGINT)) AS NEW_AMOUNT
FROM ddb_proc_log_base
WHERE (PROVID = " + docId +
" AND CHART_STATUS = 90
AND YEAR(PLDATE) = 2016
AND CLASS = 2
AND ORD = " + defer + ") OR (ORD = " + defer +
" AND PROVID = " + this.getDocHygDS.Tables[0].Rows[t]["HYG_ID"] +
" AND CHART_STATUS = 90
AND YEAR(PLDATE) = 2016 AND CLASS = 2)", conn3);
cmdBuilder5 = new SqlCommandBuilder(d8);
d8.Fill(this.balances);
相关分类