0
錯誤:其他信息:查詢表達式'[SKU N#]!='''中的語法錯誤(缺少運算符)。檢索單元格中的null和emptry字符串,同時檢索excel數據
if (getFileExtension.ToLower() == ".xls")
{
conString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + getFileName + ";Extended Properties=\"Excel 8.0;HDR=Yes;;IMEX=1\""; ;
}
else if (getFileExtension.ToLower() == ".xlsx")
{
conString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + getFileName + ";Extended Properties=\"Excel 12.0;HDR=Yes;;IMEX=1\"";
}
OleDbConnection con = new OleDbConnection(conString);
if (con.State == ConnectionState.Closed) con.Open();
System.Data.DataTable ExcelSheets = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
string SpreadSheetName = ExcelSheets.Rows[0]["TABLE_NAME"].ToString();
switch (UpdateProductViewModel.ProductDataType)
{
case 1:
query = "SELECT * FROM [" + SpreadSheetName + "] WHERE [SKU N#] !='' AND [SKU N#] NOT LIKE '%P'";
break;
case 2:
query = "SELECT * FROM [" + SpreadSheetName + "] WHERE [SKU N#] !='' AND [SKU N#] LIKE '%P'";
break;
case 3:
query = "SELECT * FROM [" + SpreadSheetName + "] WHERE [SKU N#] !=''";
break;
}
當我刪除了WHERE [SKU N#]!= ''這條線從那裏工作正常。我在這裏做錯了什麼?
嘗試'WHERE NOT [SKU N#] = '''代替。 –
@KeyurPATEL'!='不是有效的操作符? – sachin
@KeyurPATEL謝謝你的回答。它的工作。非常感謝。 –