急求~~高手进~~
如何将VBA(cad)连接上access啊 ~~<br/>高手进~~<br/>小弟新手~~<br/>急~~<br/>谢谢<br/>万分感谢~~~<br/> <p>不妨参考如下代码:<br/> Dim Cn As New Connection<br/> Cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "C:\XRCAD\DB\XRCAD.mdb" & ";Persist Security Info=False;Jet OLEDB:Database Password="123"</p><p> ...<br/></p> <p>你可以用DAO</p>你好
请问下~~dao的具体方法是怎么用的啊 本帖最后由 作者 于 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 & "\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/> startpoint(0) = rec.Fields("x1")<br/> startpoint(1) = rec.Fields("y1")<br/> startpoint(2) = 0<br/> endpoint(0) = rec.Fields("x2")<br/> endpoint(1) = rec.Fields("y2")<br/> endpoint(2) = 0 <br/> Set lineobj = ThisDrawing.ModelSpace.AddLine(startpoint, endpoint)<br/> rec.MoveNext<br/>Loop<br/>rec.Close<br/>db.Close<br/>wk.Close<br/>Unload Me<br/>End Sub<br/><br/></p>
页:
[1]