vb.net - First-chance exception at 0x761EC42D in foo.exe: Microsoft C++ exception: int at memory location 0x003ED1EC -
dim colnames(7) string dim values(7) object dim datetime = datetime.now() colnames(0) = "int1" colnames(1) = "int2" colnames(2) = "string1" colnames(3) = "string2" colnames(4) = "string3" colnames(5) = "string4" colnames(6) = "string5" colnames(7) = "string6" values(0) = intvar1 values(1) = intvar2 values(2) = strvar1 values(3) = strvar2 values(4) = strvar3 values(5) = strvar4 values(6) = strvar5 values(7) = strvar6 dim goodtoinsert boolean = true integer = 0 7 if values(i) = nothing orelse len(values(i)) = 0 goodtoinsert = false end if next if goodtoinsert accessdatabase.insertintotable("mytable", colnames, values) end if this part of code handles gathering data insert access database.
public sub insertintotable(byref tablename string, byref columnname() string, byref keyvalue() object) 'columnname , keyvalue need have same number of elements 'be careful when attemping insert value primarykey column may of type cannot manually changed 'insert new data table ' insert {tablename} ([{columnname1}], [{columnname2}], [{columnname3}], ...) values ('{string}', {number}, {boolean}, ...), oledbconnection dim columnstring string = vbnullstring dim keystring string = vbnullstring integer = 0 columnname.getupperbound(0) 'build column names part of string if <> columnname.getupperbound(0) columnstring = columnstring & "[" & columnname(i) & "], " else columnstring = columnstring & "[" & columnname(i) & "]" end if 'build values part of string dim tempvalue string = vbnullstring if keyvalue(i) <> nothing if keyvalue(i).gettype.tostring = "system.string" tempvalue = "'" & keyvalue(i) & "'" else tempvalue = keyvalue(i) end if if <> keyvalue.getupperbound(0) keystring = keystring & vbnullstring & tempvalue & ", " else keystring &= tempvalue end if else debug.print("nothing") if <> keyvalue.getupperbound(0) keystring &= ", " end if end if next dim con new oledbconnection dim da new oledbdataadapter dim sql new oledbcommand con.connectionstring = connection() con.open() dim commandtext string = "insert " & tablename & " (" & columnstring & ") values (" & keystring & ")" try sql.connection = con sql.commandtext = commandtext da.insertcommand = sql da.insertcommand.executenonquery() catch ex exception debug.print(ex.tostring) end try con.close() end sub this insertintotable function.
the function runs , inserts data table correctly, in debug output keep noticing error on every call da.insertcommand.executenonquery():
first-chance exception @ 0x761ec42d in 3024 card sorter.exe: microsoft c++ exception: int @ memory location 0x003ed1ec. first-chance exception @ 0x761ec42d in 3024 card sorter.exe: microsoft c++ exception: int @ memory location 0x003ed1ec.
i able use visual studio debugger narrow down executenonquery() being occurs, i'm having trouble understanding means, , how go resolving it. i've attempted changing intvars strings no luck resolving exception, , i'm extremely curious why isn't being caught try...catch.
Comments
Post a Comment