我有list
public List<string> strImportRequiredFields = new List<string> { "ENTRY/CMD #", "PART #", "REFERENCE 1", "REFERENCE 2", "REFERENCE 3", "DUTY PER" };
现在这是我的代码
string strFilter = string.Join(" = ' ' OR ", new UploadFields().strImportRequiredFields.Select(x => "[" + x.ToString() + "]").ToArray());
strFilter += " = ' '";
没有过滤器正在运行并提供所有行
过滤值
“[ENTRY / CMD#] =''或[PART#] =''或[参考1] =''或 [参考2] =''或[参考3] =''或[DUTY PER] =''“
string xlConn = "";
string strPath = System.Configuration.ConfigurationManager.AppSettings["UploadPath"];
xlConn = new UploadFields().returnConnectionForCSV(strPath);
OleDbConnection oledb_conn = null;
oledb_conn = new OleDbConnection(xlConn);
OleDbDataAdapter oledb_ad = new OleDbDataAdapter("SELECT * FROM [" + Path.GetFileName(filename) + "]" + " Where " + strFilter , oledb_conn);
DataTable dtImport = new DataTable();
oledb_ad.Fill(dtImport);
抛出错误
标准表达式中的数据类型不匹配。
csv Flie的样本是
ENTRY/CMD #,ENTRY TYPE,PORT,ENTRY DATE,COUNTRY OF ORIGIN,IMPORT DATE,EXPORTING COUNTRY,IMPORTER #,IMPORTER OF RECORD,TOTAL MPF,HMF,TOTAL ENTERED VALUE,BOX 37,Box 40,CD #,REC'D DATE,USED DATE,REFERENCE 1,REFERENCE 2,REFERENCE 3,REFERENCE 4,REFERENCE 5,REFERENCE 6,REFERENCE 7,REFERENCE 8,DIRECT ID,DUTIABLE,NONDUTIABLE,PART #,ALTERNATE PART #,DESCRIPTION,IMPORT QTY,AVAIL QTY,OTHER QTY,UEV 1,SPECIFIC RATE,HTSUS,LINE #,UEV 2,AD VALOREM RATE,UEV 3,OTHER RATE,UNIT OF MEASURE,BOX 37 CHECK,DUTY PER,DUTY CALCULATION CODE,YIELD,CLAIMED STATUS,Liquidation Date,RECONCILIATION ENTRY #,RECONCILIATION ENTRY DATE,PROTEST #,PROTEST DATE,POST ENTRY ADJUSTMENT DATE,DUTY STATEMENT #,DUTY STATEMENT PAID DATE,WAREHOUSE WITHDRAWAL ENTRY #,WAREHOUSE WITHDRAWAL DATE,ORIGINAL INVOICE CURRENCY VALUE,CURRENCY CODE,Currency CONVERSION RATE,Share Partner Code
55442435982,,1704,,,7/4/2010,,,,25,,10746,528.02,,,7/5/2010,,530250010,6231440010,82042000,,,,,,,,,,,"869/4 SW 8,0 x 65 mm CZ",20,20,,0.73,,8204200000,,,0.09,,,EA.,,0.0657,7,,,,,,,,,,,,,,,,
55442435982,,1704,,,7/4/2010,,,,25,,10746,528.02,,,7/5/2010,,530250020,6231440020,82042000,,,,,,,,,05060401002,,"869/4 SW 6,0 x 50 mm CZ",20,20,,0.63,,8204200000,,,0.09,,,EA.,,0.0567,7,,,,,,,,,,,,,,,,
55442435982,,1704,,,7/4/2010,,,,25,,10746,528.02,,,7/5/2010,,,6231440030,82042000,,,,,,,,,05060421002,,"869/4 M SW 6,0 x 50 mm CZ",20,20,,0.73,,8204200000,,,0.09,,,EA.,,,7,,,,,,,,,,,,,,,,
相同的代码适用于Xlsx
任何建议
谢谢
答案 0 :(得分:0)
标准不匹配通常意味着您尝试放入数据库或查询的数据无法被接受,因为数据库需要不同类型的数据。在您的情况下,您的查询需要匹配每个字段类型