本帖最后由 作者 于 2006-10-20 13:59:52 编辑
我大伙帮我看看我的vba怎么回事!
Sub ll() Dim cn As New ADODB.Connection Dim rst As New ADODB.Recordset Dim klj, blj, blj2 As String Dim tysx As String Dim id, js As Long Dim i As Integer Dim objpline As AcadLWPolyline blj = "select * from pline" klj = "provider=sqloledb.1;password=;persist security info=true;user id=sa;initial catalog=cadsql ;data source=huangbin" '库连接字符串 'klj = "Provider=MSDASQL.1ersist Security Info=False;Data Source=hbsql" cn.Open klj '连接数据库 rst.Open blj, cn, adOpenForwardOnly, adLockBatchOptimistic Dim pt() As Variant Do While Not rst.EOF js = js + 1 rst.MoveNext Loop rst.Close ReDim pt(js - 1, 2) rst.Open blj, cn, adOpenForwardOnly, adLockBatchOptimistic i = -1 Do While Not rst.EOF i = i + 1 pt(i, 0) = rst.Fields("x") pt(i, 1) = rst.Fields("y") pt(i, 2) = 0 rst.MoveNext Loop 'ThisDrawing.ModelSpace.AddLine pt Set objpline = ThisDrawing.ModelSpace.AddLightWeightPolyline_(pt) rst.Close cn.Close
End Sub
总是提示说:对象不支持该属性或方法!
我是刚接触vba的请高手们赐教!!! |