0

我有以下表达式,它从 DataRow 数组中获取传递的值 strValue 和 Selects;

expression = "InvoiceDate='" + strValue + "'"; //value in Locals window = "InvoiceDate='05/28/2013'"

我也尝试将列名作为值传递;

expression = "'" + strExpression + "'" + strValue + "'"; //value in Locals window = "InvoiceDate='05/28/2013'"

DataRow[] returnedRows; 
returnedRows = theDataConn.DataSet.Tables["Invoices"].Select(expression); //Error

它返回一个“语法错误:‘05’运算符后缺少操作数”

locals窗口中的值是一样的??我在这里想念什么?

4

1 回答 1

1

试试这个

expression = strExpression + " = '" + strValue + "'";

'请注意,我之前删除strExpression并添加了=

或使用string.Format(). 提高可读性,帮助避免代码中出现的拼写错误

expression = string.Format("{0}='{1}'", strExpression, strValue);
于 2013-07-01T18:28:21.527 回答