- UID
- 444762
- 积分
- 17
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2006-5-26
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
Imports Autodesk.AutoCAD.ApplicationServices '定义和注册新的AutoCAD命令
Imports Autodesk.AutoCAD.DatabaseServices '组成AutoCAD图形数据库的元素
Imports Autodesk.AutoCAD.Runtime '提供系统级别的功能,如DLL初始化和运行时类的注册与确认
Imports Autodesk.AutoCAD.EditorInput '提供与用户交互有关的类
Imports Autodesk.AutoCAD.Colors '与颜色有关的类
Imports Autodesk.AutoCAD.Windows '访问AutoCad中的对话框、面板、托盘、状态栏等
Imports Autodesk.AutoCAD.Geometry '用来执行2D或3D几何操作
Imports System.IO
Imports LAcadApp = Autodesk.AutoCAD.ApplicationServices.Application
Public Class LClass_Business
<CommandMethod("LInitialization")>
Public Sub LCreateLayer() '创建图层
Dim LlayerName As String = "abc"
Dim LlayerColor As Color = Color.FromColorIndex(ColorMethod.ByColor, 120) '通过颜色索引值定义颜色
Dim db As Database = HostApplicationServices.WorkingDatabase '当前工作CAD
Dim AcsConStr As String
Dim AcsCon As New ADODB.Connection
Dim SqlRs As New ADODB.Recordset
Dim i As Long
AcsConStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & My.Application.Info.DirectoryPath & "\DATA\Config.mdb;Persist Security Info=False;Jet OLEDB:Database Password=cnpccei"
Try
AcsCon.Open(AcsConStr)
SqlRs.Open("select * from Layers", AcsCon, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)
i = SqlRs.RecordCount
LlayerName = SqlRs(1).Value
LlayerColor = SqlRs("LayerColor").Value
SqlRs.Close()
AcsCon.Close()
SqlRs = Nothing
AcsCon = Nothing
Catch ex As Exception
'MsgBox(ex.Message, ex.GetType.ToString(), "打开数据库")
MsgBox(Err.Description, MsgBoxStyle.OkOnly, "打开数据库链接")
End Try
end sub
以上代码在执行到AcsCon.Open(AcsConStr)时出错
|
|