I received this SQL error in my AutoCAD plug-in application. “[Token line number =1, Token line offset = 110, Token in error = desc]”. I step through the table pulling the dbText information and pass it into my database. Based on some posts I’ve attempt adding [] around the table name and @ before the values but neither solution worked.
Using myTrans As Transaction = myDB.TransactionManager.StartTransaction
Dim myLayerTable As LayerTable = myDB.LayerTableId.GetObject(OpenMode.ForRead)
For Each myLayerID As ObjectId In myLayerTable
Dim myLayer As LayerTableRecord = myLayerID.GetObject(OpenMode.ForRead)
If myLayer <> Nothing Then
Dim name As String = myLayer.Name,
isoff As Boolean = myLayer.IsOff,
frozen As Boolean = myLayer.IsFrozen,
locked As Boolean = myLayer.IsLocked,
color As String = myLayer.Color.ColorNameForDisplay,
linetype As String = myLayer.LinetypeObjectId.ToString,
lineweight As String = myLayer.LineWeight.ToString,
transparency As String = myLayer.Transparency.ToString,
plotstyle As String = myLayer.PlotStyleNameId.ToString,
isplottable As Boolean = myLayer.IsPlottable,
vv As Boolean = myLayer.ViewportVisibilityDefault,
desc As String = myLayer.Description
Dim nd As String = "INSERT INTO layers (name, isoff, frozen, locked, color, linetype, lineweight, transparency, isplottable, vv, desc) " & _
"VALUES (" & _
"'" & name & "', " & _
"'" & isoff & "', " & _
"'" & frozen & "', " & _
"'" & locked & "', " & _
"'" & color & "', " & _
"'" & linetype & "', " & _
"'" & lineweight & "', " & _
"'" & transparency & "', " & _
"'" & isplottable & "', " & _
"'" & vv & "', " & _
"'" & desc & "')"
CeCon.DataUpdate(nd)
End If
Next
myTrans.Abort()
End Using
Private CeCon As New SqlCeConnection("Data Source=D:\Documents\Test.sdf;Persist Security Info=False;")
Private CeCmd As SqlCeCommand
Public CeDA As SqlCeDataAdapter
Public CeDT As DataTable
Public Params As New List(Of SqlCeParameter)
Public RecordCount As Integer
Public Exception As String
Public Sub ExecQuery(Query As String)
' Reset query stats
RecordCount = 0
Exception = ""
Try
CeCon.Open()
CeCmd = New SqlCeCommand(Query, CeCon)
Params.ForEach(Sub(p) CeCmd.Parameters.Add(p))
Params.Clear()
CeDT = New DataTable
CeDA = New SqlCeDataAdapter(CeCmd)
RecordCount = CeDA.Fill(CeDT)
Catch ex As Exception
Exception = ex.Message
Finally
If CeCon.State = ConnectionState.Open Then CeCon.Close()
End Try
End Sub
Public Function DataUpdate(Command As String) As Integer
Try
CeCon.Open()
CeCmd = New SqlCeCommand(Command, CeCon)
Dim ChangeCount As Integer = CeCmd.ExecuteNonQuery
CeCon.Close()
Return ChangeCount
Catch ex As Exception
MsgBox(ex.Message)
End Try
If CeCon.State = ConnectionState.Open Then CeCon.Close()
Return 0
End Function