Ho definito la seguente procedura...
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim sConn1 As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Continentale\gas.mdb"
Dim dbConn1 As OleDbConnection = New OleDbConnection(sConn1)
Dim sConn2 As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source = F:\ContinentaleVS2019\ark.accdb"
Dim dbConn2 As New OleDbConnection(sConn2)
Dim dData(100) As Date
Dim sOper(100) As String
Dim lLettura(100) As Long
Dim iI As Integer = 0
Dim iC As Integer
Dim dbComm1 As OleDbCommand = dbConn1.CreateCommand
Dim dbComm2 As OleDbCommand = dbConn2.CreateCommand
Dim r As OleDbDataReader
dbConn1.Open()
dbComm1.CommandType = CommandType.Text
dbComm1.CommandText = "SELECT id, data, operatore, lettura FROM letture"
r = dbComm1.ExecuteReader
While r.Read
dbConn2.Open()
dbComm2.CommandType = CommandType.Text
dbComm2.CommandText = "INSERT INTO gas (data, operatore, lettura) VALUES (?, ?, ?)"
dbComm2.Parameters.Add("@data", OleDbType.Date).Value = r(1)
dbComm2.Parameters.Add("@operatore", OleDbType.Char, 255).Value = r(2)
dbComm2.Parameters.Add("@lettura", OleDbType.Numeric).Value = r(3)
dbComm2.ExecuteNonQuery()
dbConn2.Close()
End While
r.Close()
dbConn1.Close()
Me.Close()
End Sub
...ma arrivato al termine mi inserisce un numero corretto di record, ma con la valorizzazione su tutti del solo primo record della tabella.
Dove sbaglio?
Grazie