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

0 Members and 1 Guest are viewing this topic.

FELIX

  • Newt
  • Posts: 121
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

  • SuperMod
  • Swamp Rat
  • Posts: 933
  • 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

Sometimes the question is more important than the answer.

FELIX

  • Newt
  • Posts: 121
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

  • Swamp Rat
  • Posts: 1450
  • BricsCAD 16
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: 2203
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

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