- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I recently updated inventor from version 2024 to 2025 and launching the exact same rule in the 2024 version everything works without a hitch, however in the 2025 version several errors appear and I am therefore unable to execute the same rule with the same conditions.
in the main rule the situation is more or less the following:
AddReference "System.Data"
AddVbFile "...\mServer.vb" ' Modulo per la gestione della connessione al DBOracle
Class ThisRule
...
Sub main()
...
mDataBase.Logger = Logger
...
If Scarica_Dati_Da_Database(queryFile) = False Then Exit Sub
...
End Sub
...
Function Scarica_Dati_Da_Database(queryLoc As String) As Boolean
Try
Dim Query As String = My.Computer.FileSystem.ReadAllText(queryLoc)
Query = Query.Replace("{LISTA}", lista)
Logger.Trace(" apro connessione server")
mDataBase.Connessione(connString)
arrayConf = mDataBase.QueryArray(Query)
mDataBase.ChiudiConnessione()
connString = Nothing
Query = Nothing
Return True
Catch ex As Exception
...
Return False
End Try
End Function
...
End Class
the problem lies in the mServer.vb 'module' or at least given the inventor's errors this is what I think
this is the complete module that I wrote last year and which in the inventor 2024 version never gave me any kind of problem:
' <IsStraightVb>True</IsStraightVb>
Imports System.Data.Odbc
Imports System.Data
Public Module mDataBase
Public property Logger As Autodesk.iLogic.Interfaces.IRuleLogger 'nel programma main richiamante aggiungere il seguente codice: mManSerr.Logger = Logger
Private connection As OdbcConnection
''' <summary>
''' Connessione al server tramite modulo ODBC
''' </summary>
Public Sub Connessione(ByVal connString As String)
Logger.Trace("**Classe cDataBase - Public Sub Connessione")
Try
connection = New OdbcConnection(connString)
' Imposta un timeout per la connessione (ad esempio, 10 secondi)
connection.ConnectionTimeout = 10
connection.Open()
Logger.Info(" Connessione aperta")
Catch ex As Exception
Logger.Error(" Connessione al server fallita: " & ex.Message)
End Try
End Sub
''' <summary>
''' Riporta il risultato di una query in un DataTable.
''' </summary>
''' <param name="queryString"></param>
''' Query da inviare al server.
''' <returns></returns>
Public Function QueryDataTable(ByVal queryString As String) As DataTable
Logger.Trace("**Classe cDataBase - Public Function QueryDataTable")
Dim dataTable As New DataTable()
Try
Dim command As New OdbcCommand(queryString, connection)
Dim dataAdapter As New OdbcDataAdapter(command)
dataAdapter.Fill(dataTable)
Logger.Debug(" DataTable compilata")
Catch ex As Exception
Logger.Error(" Errore durante l'esecuzione della query: " & ex.Message)
End Try
Return dataTable
End Function
''' <summary>
''' Riporta il risultato di una query in un Array a due dimensioni.
''' </summary>
''' <param name="queryString"></param>
''' Query da inviare al server.
''' <returns></returns>
Public Function QueryArray(ByVal queryString As String) As Object(,)
Logger.Trace("**Classe cDataBase - Public Function QueryArray")
Dim result As Object(,) = Nothing
Try
Dim command As New OdbcCommand(queryString, connection)
Dim reader As OdbcDataReader = command.ExecuteReader()
Dim columnCount As Integer = reader.FieldCount
Dim resultList As New List(Of List(Of Object))
' Aggiunta dei nomi delle colonne nella prima lista
Dim columnNames As New List(Of Object)
For i As Integer = 0 To columnCount - 1
columnNames.Add(reader.GetName(i))
Next
resultList.Add(columnNames)
' Popolamento della lista con i dati della tabella
While reader.Read()
Dim row As New List(Of Object)
For i As Integer = 0 To columnCount - 1
row.Add(reader(i).ToString())
Next
resultList.Add(row)
End While
reader.Close()
' Conversione della lista di liste in un array bidimensionale
Dim rowCount As Integer = resultList.Count
result = New Object(rowCount - 1, columnCount - 1) {}
For i As Integer = 0 To rowCount - 1
Dim row As List(Of Object) = resultList(i)
For j As Integer = 0 To columnCount - 1
result(i, j) = row(j)
Next
Next
Logger.Debug(" Limiti righe tabDataBase - Minimo: " & LBound(result, 1) & " Massimo: " & UBound(result, 1))
Logger.Debug(" Limiti colonne tabDataBase - Minimo: " & LBound(result, 2) & " Massimo: " & UBound(result, 2))
Catch ex As Exception
Logger.Error(" Errore durante l'esecuzione della query: " & ex.Message)
End Try
Return result
End Function
''' <summary>
''' Chiude connessione al server.
''' </summary>
Public Sub ChiudiConnessione()
Logger.Trace("**Classe cDataBase - Public Sub ChiudiConnessione")
Try
If connection IsNot Nothing AndAlso connection.State = ConnectionState.Open Then
connection.Close()
connection.Dispose()
Logger.Info(" Connessione chiusa")
End If
Catch ex As Exception
Logger.Error(" Errore durante la chiusura della connessione: " & ex.Message)
End Try
End Sub
End Module
the errors I receive are the following:
The type 'OdbcConnection' is not defined.
The type 'OdbcConnection' is not defined.
The type 'OdbcCommand' is not defined.
The type 'OdbcDataAdapter' is not defined.
The type 'OdbcCommand' is not defined.
The type 'OdbcDataReader' is not defined.
any ideas on what the problem could be? (I'll start by saying that I currently have both versions of Inventor 2024/2025 installed, I don't know if this could create any problems but as already said several times, everything works without any problem in Inventor 2024)
Solved! Go to Solution.