明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 971|回复: 4

急求~~高手进~~

[复制链接]
发表于 2008-4-28 10:37:00 | 显示全部楼层 |阅读模式
如何将VBA(cad)连接上access啊 ~~
高手进~~
小弟新手~~
急~~
谢谢
万分感谢~~~
发表于 2008-4-28 16:06:00 | 显示全部楼层

不妨参考如下代码:
    Dim Cn As New Connection
    Cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "C:\XRCAD\DB\XRCAD.mdb" & "ersist Security Info=False;Jet OLEDB:Database Password="123"

    ...

发表于 2008-5-2 09:56:00 | 显示全部楼层

你可以用DAO

 楼主| 发表于 2008-5-2 22:14:00 | 显示全部楼层

你好

请问下~~dao的具体方法是怎么用的啊
发表于 2008-5-3 13:24:00 | 显示全部楼层
本帖最后由 作者 于 2008-5-3 19:34:10 编辑

Private Sub CommandButton1_Click()
Dim i As Integer
Dim lineobj As Object
Dim startpoint(0 To 2) As Double
Dim endpoint(0 To 2) As Double
Dim wk As DAO.Workspace
Dim db As DAO.Database
Dim rec As DAO.Recordset

Set wk = CreateWorkspace("wk", "Admin", "", dbUseJet)
Set db = wk.OpenDatabase(ThisDrawing.Application.Path & "\1.mdb", , ",")
Dim strsql As String
strsql = "select * from points"
Set rec = db.OpenRecordset(strsql)

rec.MoveFirst
Do While Not rec.EOF
        startpoint(0) = rec.Fields("x1")
        startpoint(1) = rec.Fields("y1")
        startpoint(2) = 0
        endpoint(0) = rec.Fields("x2")
        endpoint(1) = rec.Fields("y2")
        endpoint(2) = 0      
        Set lineobj = ThisDrawing.ModelSpace.AddLine(startpoint, endpoint)
        rec.MoveNext
Loop
rec.Close
db.Close
wk.Close
Unload Me
End Sub

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-26 08:45 , Processed in 0.236794 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表