liukang2655 发表于 2011-5-10 10:39:00

关于在AUTOCAD中操作外部数据库的问题

我自定义个命令,命令中需要操作(读取)外部数据库中的数据。可是调试中出现错误:Application does not support Windows Forms just-in-time (JIT) debugging.(这个错误是在中输入命令后出现的)请问有遇到过的吗?
具体代码:
Public Sub nettext()
      Dim conn As OleDbConnection
      conn = New OleDbConnection("Provide.Microsoft.Jet.OLEDB.4.0;" & "Data Source=E:\database\Bdata.mdb")
      conn.Open()
      Dim mySQL As String
      Dim mytablename As String
      mytablename = "桥梁"
      mySQL = "select * from " & mytablename
      Dim cmd As New OleDbCommand(mySQL, conn)
      Dim dr As OleDbDataReader = cmd.ExecuteReader()
      Dim da As New OleDbDataAdapter(cmd)
      Dim ds As New DataSet
      da.Fill(ds, "桥梁")
      Dim datarow As DataRow
      Dim pt As New Point3d(100, 100, 0)
      Dim height As Double = 50
      Dim oblique As Double = 0
      For Each datarow In ds.Tables("桥梁").Rows
            Dim i As Integer = 1
            Dim text As String
            text = datarow.Item("桥名")
            ModleSpace.AddText(pt, text, height, oblique)   
            pt = New Point3d(100 + i * 500, 100, 0)
            i += 1
      Next
    End Sub
代码意图是在图纸上隔500显示数据库中的桥名。

liukang2655 发表于 2011-5-10 10:49:00

出现错误。我点继续后。仍然没有想要的结果

chmenf087 发表于 2011-5-10 14:33:00

ModleSpace.AddText(pt, text, height, oblique)   
            pt = New Point3d(100 + i * 500, 100, 0)
这貌似有问题吧,你是不是用的ActiveX对象。com接口是不能使用point3d netapi里的Structure的

liukang2655 发表于 2011-5-10 21:28:00

回复
ModleSpace.AddText(pt, text, height, oblique)没有问题。这个是在modlespace.vb模块中封装了DBText类的构造函数
Public Shared Function AddText(ByVal position As Point3d, ByVal textstring As String, ByVal height As Double, ByVal oblique As Double) As ObjectId
      Try
            Dim ent As New DBText()
            ent.Position = position
            ent.TextString = textstring
            ent.Height = height
            ent.Oblique = oblique
            Dim entId As ObjectId = AppendEntity(ent)
            Return entId
      Catch
            Dim nullId As ObjectId = ObjectId.Null
            Return nullId
      End Try
    End Function

chmenf087 发表于 2011-5-10 22:05:00


你看看你的注册表键值是不是这样的

"Auto"="0"
"Debugger"="\"C:\\WINDOWS\\system32\\vsjitdebugger.exe\" -p %ld -e %ld"
"UserDebuggerHotKey"=dword:00000000

liukang2655 发表于 2011-5-10 22:24:00

回复
是这样的啊...

chmenf087 发表于 2011-5-10 23:03:00

没有哪里有winForm,不知道你哪里出问题了,这点程序也看不出端倪,自己单步吧

sailorcwx 发表于 2011-5-11 00:04:00


感觉连接字符有问题
New OleDbConnection("Provide.Microsoft.Jet.OLEDB.4.0;" & "Data Source=E:\database\Bdata.mdb")
改成
New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source="& "E:\\database\\Bdata.mdb")
试试看

chmenf087 发表于 2011-5-11 00:12:00

呃,应该是 Provider=

liukang2655 发表于 2011-5-11 08:39:00

回复
嗯。连接字符是错了。可是修改后还是不成。你有没有写过的在命令中操作数据库的简单程序,发个,我看看。
页: [1]
查看完整版本: 关于在AUTOCAD中操作外部数据库的问题