non è identico , perchè se io eseguo questa sub routine (che tra l'altro è di background)
Mi esce fuori un eccezione alla rigacodice:Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork 'Prendo i dati da smsservergateway e li confronto con smspanel Dim Comando_SmsGateway As New OleDbCommand Dim Comando_SmsPanel As New OleDbCommand Dim Adapter_SmsGateway As New OleDbDataAdapter Dim Adapter_SmsPanel As New OleDbDataAdapter Dim Reader_SmsGateway As OleDbDataReader Dim Reader_SmsPanel As OleDbDataReader Dim ANUMBER As String Dim SMSMESSAGE As String Dim RECEIVEDDATE As Date Dim DEVICECODE As String 'Dim NUMERO As String Dim EMAIL As String Dim TESTO As String Comando_SmsGateway.Connection = Connessione_server Comando_SmsGateway.CommandText = "SELECT * FROM INBOX" Comando_SmsGateway.CommandType = CommandType.Text Adapter_SmsGateway.SelectCommand = Comando_SmsGateway Connessione_server.Open() Reader_SmsGateway = Comando_SmsGateway.ExecuteReader() While Reader_SmsGateway.Read ANUMBER = Reader_SmsGateway("ANUMBER") DEVICECODE = Reader_SmsGateway("DEVICECODE") SMSMESSAGE = Reader_SmsGateway("SMSMESSAGE") RECEIVEDDATE = Reader_SmsGateway("RECEIVEDDATE") TESTO = "Ricevuto da : " & ANUMBER & Chr(13) & "Testo : " & SMSMESSAGE & Chr(13) & "Ricevuto il : " & RECEIVEDDATE Comando_SmsPanel.Connection = Connessione Comando_SmsPanel.CommandText = "SELECT email AS email FROM numeri INNER JOIN email ON email.id_email = numeri.idemail WHERE numero = @DEVICECODE" Comando_SmsPanel.CommandType = CommandType.Text Comando_SmsPanel.Parameters.AddWithValue("@DEVICECODE", DEVICECODE) Adapter_SmsPanel.SelectCommand = Comando_SmsPanel Connessione.Open() Reader_SmsPanel = Comando_SmsPanel.ExecuteReader() Try While Reader_SmsPanel.Read() EMAIL = Reader_SmsPanel.Item("email") End While Catch ex As Exception End Try MessageBox.Show(DEVICECODE & " " & ANUMBER & " " & SMSMESSAGE & " " & RECEIVEDDATE & " " & EMAIL & " " & TESTO) Connessione.Close() 'InviaEmail(EMAIL, TESTO) System.Threading.Thread.Sleep(1500) If BackgroundWorker1.CancellationPending Then e.Cancel = True Exit While End If End While Connessione_server.Close() End Sub
che dice :codice:Reader_SmsPanel = Comando_SmsPanel.ExecuteReader()
Impossibile utilizzare oggetti COM separati dai relativi RCW sottostanti.

Rispondi quotando