I have this code and it evaluates to false instead of a string. All its doing is building a string. Any ideas why?
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" +
")"
As I mentioned in comment, you have a typo in your string concatentations:
Changing that to a
+should get you going again.With the
=in place, it was just comparing the two strings for equality (which of course isfalse) and then converting that result into the string"False".There a couple ways to avoid this kind of snafu in the future. One is to put
Option Strict Onat the top of the file, which will warn you about this kind of thing. Another would be use smaller, more manageable string chunks, so that each one has a lower probability of being the problem.In terms of debugging something like this, I compiled the code, then opened it using ILSpy. It showed the code being generated (i.e. the string compare) as well as which strings were actually being compared. Seeing that made it easy to locate the offending
=(since it appeared right after the end of the first argument to the string comparison.)