sql - ADODB connection to ACCDB file -- unrecognized database format error -


i have file this:

strpath = "s:\hr\forms\forms_database.accdb" 

i connecting through word adodb.connection

should database different extension ? mdb or something?

i getting error when tries connect:

unrecognized database format 's:...............accdb' 

what's going on here?

here's entire code:

sub transfershipper()    'transfer new shipping company record    'shippers table in northwind database.    dim cnn adodb.connection   dim strconnection string   dim strsql string   dim strpath string   dim doc word.document   dim strcompanyname string   dim strphone string   dim bytcontinue byte   dim lngsuccess long   set doc = thisdocument   on error goto errhandler    strcompanyname = chr(39) & doc.formfields("txtcompanyname").result & chr(39)   strphone = chr(39) & doc.formfields("txtphone").result & chr(39)   'confirm new record.   bytcontinue = msgbox("do want insert record?", vbyesno, "add record")   debug.print bytcontinue   'process input values.   if bytcontinue = vbyes     strsql = "insert vacation " _      & "(title, department) " _      & "values (" _      & strcompanyname & ", " _      & strphone & ")"     debug.print strsql     'substitute path , connection string dsn if available.     strpath = "s:\hr\forms\forms_database.accdb"     strconnection = "provider=microsoft.jet.oledb.4.0;" _      & "data source = " & strpath     debug.print strconnection     set cnn = new adodb.connection     cnn.open strconnection     cnn.execute strsql, lngsuccess     cnn.close     msgbox "you inserted " & lngsuccess & " record", _      vbokonly, "error added"     doc.formfields("txtcompanyname").textinput.clear     doc.formfields("txtphone").textinput.clear   end if   set doc = nothing   set cnn = nothing   exit sub errhandler:   msgbox err.number & ": " & err.description, _    vbokonly, "error"   on error goto 0   on error resume next   cnn.close   set doc = nothing   set cnn = nothing end sub 

try ace oledb 12.0 db version.

"provider=microsoft.ace.oledb.12.0" 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -