vb.net - Parameters - Multiple-step OLE DB operation generated errors -


i'm new vb.net , stackoverflow. i'm in little project application take excel file , upload access database backend.

at moment have managed import excel file want datatable (dt) having problems updating backend access database.

i imagine problem parameters being passed - keep getting 'multiple-step ole db operation generated errors' , have tried setting datatypes. appreciated

dim con new oledb.oledbconnection(connect)         dim update new oledb.oledbcommand("update queries set subjstatus=@p1, status=@p2, age=@p3, closeddate=@p4, closedtime=@p5, closedby=@p6, closedbyrole=@p7 " & _                                              "where study=@p8 , rvlid=@p9 , visitname=@p10 , formname=@p11 , pageno=@p12 , fieldname=@p13 , description=@p14" & _                                              " , createdate=@p15 , createtime=@p16 , createdby=@p17", con)          'get values excel - datatable          update.parameters             .addwithvalue("@p1", dt.columns("subject status"))             .addwithvalue("@p2", dt.columns("query status"))             .addwithvalue("@p3", dt.columns("query age (days)"))             .addwithvalue("@p4", dt.columns("query closed date"))             .addwithvalue("@p5", dt.columns("query closed time"))             .addwithvalue("@p6", dt.columns("query closed by"))             .addwithvalue("@p7", dt.columns("query closed role"))             .addwithvalue("@p8", dt.columns("protocol number"))             .addwithvalue("@p9", dt.columns("screening number"))             .addwithvalue("@p10", dt.columns("visit name"))             .addwithvalue("@p11", dt.columns("form name"))             .addwithvalue("@p12", dt.columns("page number"))             .addwithvalue("@p13", dt.columns("field name"))             .addwithvalue("@p14", dt.columns("query text"))             .addwithvalue("@p15", dt.columns("query creation date (utc)"))             .addwithvalue("@p16", dt.columns("query creation time (utc)"))             .addwithvalue("@p17", dt.columns("query created by"))         end          'execute sql command         con.open()         update.executenonquery() 

i managed decent solution using combination of these 2 links

  1. update dataadapter1
  2. update dataadapter2

i defined parameters follows

.add("@p6", oledb.oledbtype.longvarchar, 255, "page number") .add("@p7", oledb.oledbtype.longvarchar, 255, "field name") 

i needed make sure rows in datatable (dt) set think changes has happened.

for each row datarow in dt.rows if row.rowstate = datarowstate.added or datarowstate.unchanged row.setadded() end if next

then update using data adapter (after defining update, insert commands)

da.update(dt)

please let me know if there better method.


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -