gifttang66 发表于 2008-4-28 10:37:00

急求~~高手进~~

如何将VBA(cad)连接上access啊 ~~<br/>高手进~~<br/>小弟新手~~<br/>急~~<br/>谢谢<br/>万分感谢~~~<br/>

zhihaoli_bj 发表于 2008-4-28 16:06:00

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

jsf1117 发表于 2008-5-2 09:56:00

<p>你可以用DAO</p>

gifttang66 发表于 2008-5-2 22:14:00

你好

请问下~~dao的具体方法是怎么用的啊

azjmjsj 发表于 2008-5-3 13:24:00

本帖最后由 作者 于 2008-5-3 19:34:10 编辑 <br /><br /> <p>Private Sub CommandButton1_Click()<br/>Dim i As Integer<br/>Dim lineobj As Object<br/>Dim startpoint(0 To 2) As Double<br/>Dim endpoint(0 To 2) As Double<br/>Dim wk As DAO.Workspace<br/>Dim db As DAO.Database<br/>Dim rec As DAO.Recordset</p><p>Set wk = CreateWorkspace("wk", "Admin", "", dbUseJet)<br/>Set db = wk.OpenDatabase(ThisDrawing.Application.Path &amp; "\1.mdb", , ",")<br/>Dim strsql As String<br/>strsql = "select * from points" <br/>Set rec = db.OpenRecordset(strsql)</p><p>rec.MoveFirst<br/>Do While Not rec.EOF<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; startpoint(0) = rec.Fields("x1")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; startpoint(1) = rec.Fields("y1")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; startpoint(2) = 0<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; endpoint(0) = rec.Fields("x2")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; endpoint(1) = rec.Fields("y2")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; endpoint(2) = 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set lineobj = ThisDrawing.ModelSpace.AddLine(startpoint, endpoint)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rec.MoveNext<br/>Loop<br/>rec.Close<br/>db.Close<br/>wk.Close<br/>Unload Me<br/>End Sub<br/><br/></p>
页: [1]
查看完整版本: 急求~~高手进~~