我试图将数据存储在数据行中,它将显示此错误 [英] I am trying to store data in data row it will show this error
本文介绍了我试图将数据存储在数据行中,它将显示此错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ERROR:The items following the IN keyword must be separated by commas and be enclosed in parentheses.
我的代码是
我的尝试:
DataRow [] rows = dt.Select(CompanyID不在oCompanyBO.SelectedSupplierIDs中);
my code is
What I have tried:
DataRow[] rows = dt.Select("CompanyID not in oCompanyBO.SelectedSupplierIDs");
推荐答案
无法确定这么少的信息,但我认为你的问题是你在字符串中嵌入变量名,当你想要使用变量的值时。
Cannot be sure with so little information, but I think that your problem is that you embed a variable name in a string, when you want to use the value of the variable.
DataRow[] rows = dt.Select("CompanyID not in oCompanyBO.SelectedSupplierIDs");
应该是
should be
DataRow[] rows = dt.Select(string.Format("CompanyID not in ({0})", oCompanyBO.SelectedSupplierIDs));
if oCompanyBO.SelectedSupplierIDs
是逗号分隔列表。
但是,如果 oCompanyBO.SelectedSupplierIDs
是一个SelectedSupplierID(int)数组,那么你需要先创建一个逗号分隔的字符串
if oCompanyBO.SelectedSupplierIDs
is a comma separated list.
However, if oCompanyBO.SelectedSupplierIDs
is an array of SelectedSupplierID (int) then you need to first create a comma separated string
string idList = string.Join(",", oCompanyBO.SelectedSupplierIDs);
DataRow[] rows = dt.Select(string.Format("CompanyID not in ({0})", idList));
这篇关于我试图将数据存储在数据行中,它将显示此错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文