欢迎来到天天文库
浏览记录
ID:1197094
大小:67.00 KB
页数:9页
时间:2017-11-08
《autocad lisp操作数据库》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、LISP操作数据库数据库,LISP(defunDbInitADO(/ADO_DLLPath)(if(nulladom-Append)(progn(setqADO_DLLPath(strcat(getenv"systemdrive")"\ProgramFiles\CommonFiles\System\Ado\"));;如果查找到类型库...(if(findfile(strcatADO_DLLPath"msado15.dll"));;将其输入(vlax-Import-Type-Library:tlb-filename(str
2、catADO_DLLPath"msado15.dll"):methods-prefix"adom-":properties-prefix"adop-":constants-prefix"adok-");;找不到时,则通知操作者(alert(strcat"不能找到以下文件"ADO_DLLPath"msado15.dll"))))));生成MS-Access或MS-SQLServer数据库的连接字符串;;;***************************************************************
3、***;;;使用ODBC(不需要DSN)连接MS-Access数据库;;;示例:(DbConnect_MSAccess1"d:/dbfiles/products.mdb");;;******************************************************************(defunDbConnect_MSAccess1(dbFile)(strcat"Provider=MSDASQL;""Driver={MicrosoftAccessDriver(*.mdb)};""DBQ="dbFile))
4、;从内存中释放VLA对象(defunMxRelease(xObject)vlax-object-released-p(if(not(vlax-object-released-pxObject))(vlax-Release-ObjectxObject)));关闭ADOConnection对象并将内存释放出来(defunDbCloseConnection(dbConnObject)(vlax-Invoke-MethoddbConnObject"Close")(MxReleasedbConnObject));关闭ADORecordSet
5、对象并将内存释放出来(defunDbCloseRecordset(rsObject)(vlax-Invoke-MethodrsObject"Close")(MxReleasersObject));布尔测试RecordSet是否为Closed(T或nil)(defunDbRsIsClosed(rsObject)(=adok-adStateClosed(vlax-Get-PropertyrsObject"State")));返回一个ADORecordSet对象中的记录数(defunDbRsCount(rsObject)(vlax-Ge
6、t-PropertyrsObject"RecordCount"));返回Field对象中给定字段数的字段名称(defunDbGetFields(fObjectfCount/FieldNumber)(setqFieldNumber-1)(while(>fCount(setqFieldNumber(1+FieldNumber)))(setqFieldList(cons(vlax-Get-Property(DbRsFieldItemFieldsObjectFieldNumber)"Name")FieldList));setq);endw
7、hile);defun;从RecordSet对象返回ADOField对象(defunDbRsFields(rsObject)(vlax-Get-PropertyrsObject"Fields"));返回给定Field对象的字段数量(defunDbRsFieldCount(fObject)(vlax-Get-PropertyfObject"Count"));获取Field对象的字段名(项)(defunDbRsFieldItem(fObjectfNumber)(vlax-Get-PropertyfObject"Item"fNumber
8、));返回RecordSet对象的RowSet对象(defunDbRsGetRows(rsObject)(vlax-Invoke-MethodrsObject"GetRows"adok-adGetRowsRest));应用一个ADOLOCK(锁定)
此文档下载收益归作者所有