我有这个代码,它的结果是false而不是字符串。它所做的就是构建一个字符串。有什么想法吗?
Dim statement As String = "Insert into table dbo.IV00101 values(" +
"ITEMNMBR=" + "@ITEMNMBR" + "," +
"ITEMDESC=" + "@ITEMDESC" + " , " +
"NOTEINDX=" + "@NOTEINDX" + "," +
"ITMSHNAM=" + DBNull.Value + "," +
"ITEMTYPE=" + "1" + "," +
"STNDCOST=" + "@STNDCOST" + "," +
"CURRCOST=" + "@CURRCOST" + "," +
"ITEMSHWT=" + "0" + "," +
"DECPLQTY=" + "3" + "," +
"DECPLCUR=" + "3" + "," +
"ITMTSHID=" + DBNull.Value + "," +
"TAXOPTNS=" + "1" + "," +
"IVIVINDX=" + "0" + "," +
"IVIVOFIX=" + "0" + "," +
"IVCOGSIX=" + "0" + "," +
"IVSLSIDX=" + "0" + "," +
"IVSLDSIX=" + "0" + "," +
"IVSLRNIX=" + "0" + "," +
"IVINUSIX=" + "0" + "," +
"IVINSVIX=" + "0" + "," +
"IVDMGIDX=" + "0" + "," +
"IVVARIDX=" + "0" + "," +
"DPSHPIDX=" + "0" + "," +
"PURPVIDX=" + "0" + "," +
"UPPVIDX=" + "0" + "," +
"IVRETIDX" + "0" + "," +
"ASMVRIDX=" + "0" + "," +
"ITMCLSCD=" + DBNull.Value + "," +
"ITMTRKOP=" + "1" + "," +
"LOTTYPEAC=" + DBNull.Value + "," +
"KPERHIST=" + "0" + "," +
"KPTRXHST=" + "0" + "," +
"KPCALHST=" + "0" + "," +
"KPDSTHST=" + "0" + "," +
"ALWBKORD=" + "0" + "," +
"VCTNMTHD=" + "1" + "," +
"UOMSCHDL=" + "@UOMSCHDL" + "," +
"ALTITEM1=" + DBNull.Value + "," +
"ALTITEM2=" + DBNull.Value + "," +
"USCATVLS_1=" + DBNull.Value + "," +
"USCATVLS_2=" + DBNull.Value + "," +
"USCATVLS_3=" + DBNull.Value + "," +
"USCATVLS_5=" + DBNull.Value + "," +
"USCATVLS_4=" + DBNull.Value + "," +
"USCATVLS_6=" + DBNull.Value + "," +
"MSTRCDTY=" + "1" + "," +
"MODIFDT=" + Date.Today.ToString() + "," +
"CREATDDT=" + Date.Today.ToString() + "," +
"WRNTYDYS=" + "0" + "," +
"PRCLEVEL=" + DBNull.Value + "," +
"LOCNCODE=" + DBNull.Value + "," +
"PINFLIDX=" + "0" + "," +
"PURMCIDX=" + "0" + "," +
"IVINFIDX=" + "0" + "," +
"INVMCIDX=" + "0" + "," +
"CGSINFLX=" + "0" + "," +
"CGSMCIDX=" + "0" + "," +
"ITEMCODE=" + DBNull.Value + "," +
"TCC=" + DBNull.Value + "," +
"PriceGroup=" + DBNull.Value + "," +
"PRICMTHD=" + "1" + "," +
"PRCHSUOM=" + DBNull.Value + "," +
"SELNGUOM=" + DBNull.Value + "," +
"KTACCTSR=" + "0" + "," +
"LASTGENSN=" = DBNull.Value + "," +
"ABCCODE=" + "1" + "," +
"Revalue_Inventory=" + "1" + "," +
"Tolerance_Percentage=" + "0" + "," +
"Purchase_Item_Tax_Schedu=" + DBNull.Value + "," +
"Purchase_Tax_Options=" + "1" + "," +
"ITMPLNNNGTYP=" + "1" + "," +
"STTSTCLVLPRCNTG=" + "0" + "," +
"CNTRYORGN=" + DBNull.Value + "," +
"INACTIVE=" + "0" + "," +
"MINSHELF1=" + "0" + "," +
"MINSHELF2=" + "0" + "," +
"INCLUDEINDP=" + "0" + "," +
"LOTEXPWARN=" + "0" + "," +
"LOTEXPWARNDAYS=" + "0" + "," +
"LASTGENLOT=" + DBNull.Value + "," +
"Lot_Split_Quantity=" + "0.00000" + "," +
"DEX_ROW_TS=" + Date.Today.ToString() + "," +
"DEX_RoW_ID=" + "@DEX_RoW_ID" +
")"
答案 0 :(得分:5)
正如我在评论中提到的,你的字符串连接中有一个拼写错误:
"KTACCTSR=" + "0" + "," +
"LASTGENSN=" ***=*** DBNull.Value + "," +
"ABCCODE=" + "1" + "," +
将其更改为+
会让您重新开始。
在=
到位的情况下,只是比较两个字符串的相等性(当然是false
),然后将那个结果转换为字符串{{ 1}}。
将来有几种方法可以避免这种混乱。一种是将"False"
放在文件的顶部,这将警告你这种事情。另一种方法是使用更小,更易于管理的字符串块,这样每个字符串的概率都会降低。
在调试这样的事情方面,我编译了代码,然后使用ILSpy打开它。它显示了生成的代码(即字符串比较)以及实际被比较的字符串。看到这样可以很容易地找到有问题的Option Strict On
(因为它出现在字符串比较的第一个参数结束之后。)