Sto disperatamente provando ad utilizzare un OleDbCommand per aggiornare dei record in una tabella di access. Il mio codice è:
Dim objCommand As New OleDb.OleDbCommand()
With objCommand
.CommandText = "UPDATE Cliente SET Cliente.CodCliente = ?, Cliente.Cliente = ?, " & _
"Cliente.PIVACodFiscale = ?, Cliente.Indirizzo = ?, Cliente.CAP = ?, " & _
"Cliente.Citta = ?, Cliente.Provincia = ?, Cliente.Telefono = ?, Cliente.Fax = ?, " & _
"Cliente.Email = ?, Cliente.appunti = ? WHERE (((Cliente.IDCliente)=?))"
.CommandType = CommandType.Text
.Connection = Me.OleDbConnection1
Dim objParameters As New OleDb.OleDbParameter()
objParameters = .Parameters.Add("CodCliente", System.Data.OleDb.OleDbType.VarWChar, 50)
objParameters.Direction = ParameterDirection.Input
objParameters.Value = Me.tbCodCliente.Text
objParameters = .Parameters.Add("Cliente", System.Data.OleDb.OleDbType.VarWChar, 100)
objParameters.Direction = ParameterDirection.Input
objParameters.Value = Me.tbCliente.Text
objParameters = .Parameters.Add("PivaCodFiscale", System.Data.OleDb.OleDbType.VarWChar, 50)
objParameters.Direction = ParameterDirection.Input
objParameters.Value = Me.tbPIVACodFiscale.Text
objParameters = .Parameters.Add("Indirizzo", System.Data.OleDb.OleDbType.VarWChar, 255)
objParameters.Direction = ParameterDirection.Input
objParameters.Value = Me.tbIndirizzo.Text
objParameters = .Parameters.Add("CAP", System.Data.OleDb.OleDbType.VarWChar, 10)
objParameters.Direction = ParameterDirection.Input
objParameters.Value = Me.tbCap.Text
objParameters = .Parameters.Add("Citta", System.Data.OleDb.OleDbType.VarWChar, 100)
objParameters.Direction = ParameterDirection.Input
objParameters.Value = Me.tbLocalità.Text
objParameters = .Parameters.Add("Provincia", System.Data.OleDb.OleDbType.VarWChar, 100)
objParameters.Direction = ParameterDirection.Input
objParameters.Value = Me.tbProvincia.Text
objParameters = .Parameters.Add("Telefono", System.Data.OleDb.OleDbType.VarWChar, 20)
objParameters.Direction = ParameterDirection.Input
objParameters.Value = Me.tbTelefono.Text
objParameters = .Parameters.Add("Fax", System.Data.OleDb.OleDbType.VarWChar, 20)
objParameters.Direction = ParameterDirection.Input
objParameters.Value = Me.tbFax.Text
objParameters = .Parameters.Add("Email", System.Data.OleDb.OleDbType.VarWChar, 100)
objParameters.Direction = ParameterDirection.Input
objParameters.Value = Me.tbEmail.Text
objParameters = .Parameters.Add("Appunti", System.Data.OleDb.OleDbType.VarWChar, 1000)
objParameters.Direction = ParameterDirection.Input
objParameters.Value = Me.tbAppunti.Text
objParameters = .Parameters.Add("IDCliente", System.Data.OleDb.OleDbType.Integer, 0)
objParameters.Direction = ParameterDirection.Input
objParameters.Value = Me.tbIdCliente.Text
End With
Try
Me.OleDbConnection1.Open()
objCommand.ExecuteNonQuery()
Catch ex As OleDb.OleDbException
Response.Write(ex.Message & ex.ErrorCode)
Finally
Me.OleDbConnection1.Close()
End Try
A me sembra tutto perfetto però continuo a ricevere l'errore:
Per l'operazione è necessaria una query aggiornabile
Chi mi sa aiutare? Io non ne vengo fuori....
Grazie