Author Topic: Error open MDB ADO Connection  (Read 1396 times)

0 Members and 1 Guest are viewing this topic.

FELIX

  • Bull Frog
  • Posts: 241
Error open MDB ADO Connection
« on: April 15, 2017, 07:12:32 PM »
Code: [Select]
(vl-load-com)
 (setq ADOConnect   (vlax-create-object "ADODB.Connection")
       ADORecordset (vlax-create-object "ADODB.Recordset")
 ) ;_  setq
 (vlax-invoke-method ADOConnect
                     "Open"
                     (strcat "Driver={Microsoft Access Driver (*.mdb)};DBQ=" file)
                     "Admin"
                     ""
                     0
 )

error: Automation Error. [Microsoft][ODBC Driver Manager]
Data source name not found and no default driver specified
?
OK.

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2125
  • class keyThumper<T>:ILazy<T>
Re: Error open MDB ADO Connection
« Reply #1 on: April 15, 2017, 07:51:34 PM »
What is the value of the 'file' variable ??

(strcat "Driver={Microsoft Access Driver (*.mdb)};DBQ=" file)
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

FELIX

  • Bull Frog
  • Posts: 241
Re: Error open MDB ADO Connection
« Reply #2 on: April 15, 2017, 09:04:38 PM »
Is the first time I use access to an mdb in VisualLisp. If you have another suggestion, thank you.

Code: [Select]
(vl-load-com)
(setq fn (findfile "d:\\test.mdb"))
(setq processor_type (getenv "processor_architecture"))
(if (= processor_type "AMD64")
  (setq strconn (STRCAT "Provider=MSDASQL;Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=" fn))
  (setq strconn (strcat "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" fn ";Persist Security Info=False"))
)
(setq ADOConnect   (vlax-create-object "ADODB.Connection")
      ADORecordset (vlax-create-object "ADODB.Recordset")
)
(vlax-invoke-method ADOConnect "Open" strconn "Admin" "" 0)
OK.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Error open MDB ADO Connection
« Reply #3 on: April 16, 2017, 08:05:14 AM »
Maybe this helps:
For the connection string I use:
Code: [Select]
(strcat
  (if (vl-registry-read "HKEY_CLASSES_ROOT\\Microsoft.ACE.OLEDB.12.0")
    "Provider=Microsoft.ACE.OLEDB.12.0;"
    "Provider=Microsoft.Jet.OLEDB.4.0;"
  )
  "Data Source="
  fileName
  ";"
  "Persist Security Info=False;"
)

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: Error open MDB ADO Connection
« Reply #4 on: April 17, 2017, 10:27:32 AM »
What version and bit-ness of Office do you have installed?  I'm assuming x64 AutoCAD; if you have Office 2010 it cannot be x32 (some have been able to install the x64 Access drivers alongside but I've always had problems).  Generally best if you install x64 Office, unless you have other applications which are dependent on the x32 Access drivers.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

FELIX

  • Bull Frog
  • Posts: 241
Re: Error open MDB ADO Connection
« Reply #5 on: April 17, 2017, 03:59:10 PM »
It worked. Thank you all.
OK.