我有這個代碼,它的計算結果是false而不是字符串。它所做的一切都是建立一個字符串。任何想法爲什麼?爲什麼在VB.Net中評估爲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" +
")"
所有舊評論去哪了? – user489041
這條「線」有問題的事實很好地表明,一個字符串構建循環會是一個更好的實現。正如@dlev發現的,** 249 **加上符號中的一個是錯誤的。一個循環最多隻能有四個加號,這種錯誤會立即顯示出來。 –
在Visual Basic中連接字符串時,最好使用&運算符而不是+。 +運算符有一套複雜的規則來決定是否添加,連接或拋出錯誤。 &運算符僅用於字符串操作數,並始終將其操作數擴展爲String。 – briddums