2011-09-08 20 views
1

私はこのコードを持っており、文字列ではなく偽と評価されます。そのすべては文字列を作成しています。なぜどんなアイデア?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" + 
     ")" 
+0

すべての古いコメントはどこに行きましたか? – user489041

+0

この "行"に問題があるという事実は、ストリング構築ループがより良い実装になることを示す良い指標です。 @dlevが発見されたので、** 249 **プラスシンボルの1つだけがエラーになりました。ループには4つのプラス記号maxしかないので、この種のエラーはすぐに表示されます。 –

+1

ビジュアルベーシックで文字列を連結するときは、+の代わりに&演算子を使用する方が良いでしょう。 +演算子には、エラーを追加、連結、またはスローするかどうかを判断するための複雑なルールセットがあります。 &演算子は文字列オペランドのみであり、常にオペランドをStringに拡張します。 – briddums

答えて

5

私はコメントで述べたように、あなたはあなたの文字列concatentationsにタイプミスがあります

"KTACCTSR=" + "0" + "," + 
"LASTGENSN=" ***=*** DBNull.Value + "," + 
"ABCCODE=" + "1" + "," + 

+にあなたが再び軌道に乗る必要があることを変更します。代わりに=

、それだけで平等のための2つの文字列を比較する(もちろんfalseである)、次に文字列"False"その結果を変換しました。

今後この種の鼻水を避けるには、いくつかの方法があります。 1つは、ファイルの先頭にOption Strict Onを入れることです。これは、この種のことを警告します。もう一つは、より小さく、より管理しやすい文字列チャンクを使用するため、それぞれが問題になる可能性が低くなります。

このようなデバッグに関しては、コードをコンパイルしてからILSpyを使用してオープンしました。これは、生成されたコード(すなわち、文字列比較)と、実際にどの文字列が比較されているかを示しています。これは、文字列比較の最初の引数の終わりの直後に現れたので、=を見つけやすくなりました。

+1

ひどい混乱でよく見られます。 +1。 – driis

関連する問題