.net - Parameters.AddWithValue failing -
i'm getting "system.formatexception: input has wrong format." error on second attempt while first 1 works fine.
does see why so?
attempt 1:
using ncmdins1 sqlite.sqlitecommand = cnuser.createcommand ncmdins1 .commandtext = "insert images (oemimageguid,imagetitle,imagecategory,imagesize,imageblob256) values (@1,@2,@3,@4,@5)" .parameters.add("@1", dbtype.string).value = uoemimageguid .parameters.add("@2", dbtype.string).value = utitle .parameters.add("@3", dbtype.int32).value = icat .parameters.add("@4", dbtype.int32).value = uimagesize .parameters.add("@5", dbtype.binary).value = ubytes .executenonquery() end end using
attempt 2:
using ncmdins2 sqlite.sqlitecommand = cnuser.createcommand ncmdins2 .commandtext = "insert images (oemimageguid,imagetitle,imagecategory,imagesize,imageblob256) values (@1,@2,@3,@4,@5)" .parameters.addwithvalue("@1", dbtype.string).value = uoemimageguid .parameters.addwithvalue("@2", dbtype.string).value = utitle .parameters.addwithvalue("@3", dbtype.int32).value = icat .parameters.addwithvalue("@4", dbtype.int32).value = uimagesize .parameters.addwithvalue("@5", dbtype.binary).value = ubytes .executenonquery() end end using
i've tried isolate problem removing parameters , values 1 one, in end, got same error sparse line:
using ncmdins3 sqlite.sqlitecommand = cnuser.createcommand ncmdins3 .commandtext = "insert images (oemimageguid) values (@1)" .parameters.addwithvalue("@1", dbtype.string).value = uoemimageguid .executenonquery() end end using
here screenshot of exception attempt 3:
the second parameter of addwithvalue value itself, not type
see msdn addwithvalue
in case try use first method because have more control on type of parameter.
can stop using addwithvalue already?
using ncmdins2 sqlite.sqlitecommand = cnuser.createcommand ncmdins2 .commandtext = "insert images (oemimageguid,imagetitle,imagecategory,imagesize,imageblob256) values (@1,@2,@3,@4,@5)" .parameters.addwithvalue("@1", uoemimageguid) .parameters.addwithvalue("@2", utitle) .parameters.addwithvalue("@3", icat) .parameters.addwithvalue("@4", uimagesize) .parameters.addwithvalue("@5", ubytes) .executenonquery() end end using
Comments
Post a Comment