sql - Database Update in VBA -


sub uoload_data()     dim s(40) integer     dim row integer     dim integer     = 0     row = 7 39         s(i) = sheets("data").cells(row, 5).value         = + 1     next     dim cn object     dim rs object     dim strsql string     dim strconnection string     dim apppath string     set cn = createobject("adodb.connection")     apppath = application.activeworkbook.path     strconnection = "provider=microsoft.ace.oledb.12.0;" & _         "data source=c:\users\devi\desktop\ability.accdb;"     cn.open strconnection     strsql = "insert mytable values ('" & s(0) & " ',         '" & s(1) & " ','" & s(2) & " ','" & s(3) & " ' )"     set rs = cn.execute(strsql)     set rs = nothing     cn.close     set cn = nothing end sub 

i have excel sheet of 40 field. update field access database. while insert record database using insert statement. in mean time need write fields of array insert statement. please me out compact statement.

you can use join() here

strsql = "insert mytable values ('" & join(s, "','") & "')" 

the values in s() integers, you're wrapping values in single-quotes, db columns text-type?

if numeric columns should drop single-quotes.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -