LISP 操作数据库
数据库, LISP
(defun DbInitADO ( / ADO_DLLPath)
(if (null adom-Append)
(progn
(setq ADO_DLLPath
(strcat (getenv "systemdrive")
"\Program Files\Common Files\System\Ado\")
)
;; 如果查找到类型库 ...
(if (findfile (strcat ADO_DLLPath "msado15.dll")) ;; 将其输入
(vlax-Import-Type-Library
:tlb-filename (strcat ADO_DLLPath "msado15.dll")
:methods-prefix "adom-"
:properties-prefix "adop-"
:constants-prefix "adok-"
)
;; 找不到时,则通知操作者
(alert (strcat "不能找到以下文件" ADO_DLLPath "msado15.dll"))
)
)
)
)
;生成 MS-Access 或 MS-SQL Server 数据库的连接字符串
;;;******************************************************************
;;; 使用 ODBC(不需要 DSN)连接 MS-Access 数据库
;;; 示例: (DbConnect_MSAccess1 "d:/dbfiles/products.mdb")
;;;******************************************************************
(defun DbConnect_MSAccess1 (dbFile)
(strcat
"Provider=MSDASQL;"
"Driver={Microsoft Access Driver (*.mdb)};"
"DBQ=" dbFile
)
)
;从内存中释放 VLA 对象
(defun MxRelease (xObject)
vlax-object-released-p
(if (not (vlax-object-released-p xObject))
(vlax-Release-Object xObject)
评论0