Wednesday, 15 January 2014

vb.net - How to convert varchar to integer -



vb.net - How to convert varchar to integer -

i'm trying commit values database using info grid viewer,but when press submit button displaying message saying

error converting info type varchar numeric.

but record sucessfully added database.

this query

"objcon.doexecute("insert orderitemf values('" & dgorder.item("item no", i).value & "','" & dgorder.item("item type", i).value & "','" & txtodrno.text & "','" & dgorder.item("unit price", i).value & "','" & dgorder.item("quantity", i).value & "','" & dgorder.item("discount", i).value & "','" & dgorder.item("total value", i).value & "')")"

i used doexecute method execute sql string.in here dgorder info grid viewer name.in database table unitprice,discount,quantity , total value represent info type decimal.tell me how convert these info grid viewer varchar values decimal?

if underlying column numeric must not wrap value passing in apostrophes. likewise if filtering on numeric column same rule applies.

it bad practice create sql string in way, improve off using parameters. sqlcommand object has parameters collection, professional way

vb.net

No comments:

Post a Comment