TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: FELIX on April 15, 2017, 07:12:32 PM
-
(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
?
-
What is the value of the 'file' variable ??
(strcat "Driver={Microsoft Access Driver (*.mdb)};DBQ=" file)
-
Is the first time I use access to an mdb in VisualLisp. If you have another suggestion, thank you.
(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)
-
Maybe this helps:
For the connection string I use:
(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;"
)
-
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.
-
It worked. Thank you all.