codice:
Dim myConnection As OleDbConnection = New OleDbConnection(strConnElab)
myConnection.Open()
myDa = New OleDbDataAdapter
myDs = New DataSet
'SELECT
Dim mySelectCommand As OleDbCommand = New OleDbCommand
strsql = "select idprog,cartella,nontrovate,targa,verbale,datainfra,spazio,"
strsql &= "importorichiesto,posizione,pagare,disctot,discparz,codpagamento,brand,ente from
CartelleProcessate"
strsql &= " where cartella='" & ComboBox1.Text & "'"
mySelectCommand.CommandText = strsql
mySelectCommand.Connection = myConnection
'UPDATE
Dim myUpdateCommand As OleDbCommand = New OleDbCommand()
strsql = "UPDATE CartelleProcessate SET "
strsql &= "DiscParz=?,"
strsql &= "DiscTot=?,"
strsql &= "pagare=?"
strsql &= " WHERE idProg=?"
myUpdateCommand.CommandText = strsql
myUpdateCommand.Connection = myConnection
myUpdateCommand.CommandType = CommandType.Text
myUpdateCommand.Parameters.Add(New System.Data.OleDb.OleDbParameter("DiscParz",
System.Data.OleDb.OleDbType.Boolean, 0, System.Data.ParameterDirection.Input, CType(0, Byte),
CType(0, Byte), "DiscParz", System.Data.DataRowVersion.Current, False, Nothing))
myUpdateCommand.Parameters.Add(New System.Data.OleDb.OleDbParameter("DiscTot",
System.Data.OleDb.OleDbType.Boolean, 0, System.Data.ParameterDirection.Input, CType(0, Byte),
CType(0, Byte), "DiscTot", System.Data.DataRowVersion.Current, False, Nothing))
myUpdateCommand.Parameters.Add(New System.Data.OleDb.OleDbParameter("Pagare",
System.Data.OleDb.OleDbType.Boolean, 0, System.Data.ParameterDirection.Input, CType(0, Byte),
CType(0, Byte), "Pagare", System.Data.DataRowVersion.Current, False, Nothing))
myUpdateCommand.Parameters.Add(New System.Data.OleDb.OleDbParameter("idProg",
System.Data.OleDb.OleDbType.BigInt, 0, System.Data.ParameterDirection.Input, CType(0, Byte),
CType(0, Byte), "idProg", System.Data.DataRowVersion.Original, False, Nothing))
'aggiungo i command al dataset
myDa.SelectCommand = mySelectCommand
myDa.UpdateCommand = myUpdateCommand
myDa.Fill(myDs, "CartelleProcessate") 'aggiunto il nome della tabella
'========================================================================
'abilito l'evento ColumnChanging per validare i dati 'li vado a salvare
AddHandler myDs.Tables("CartelleProcessate").ColumnChanging, AddressOf
dtgFlag_ColumnChanging
'========================================================================
dtgFlag.DataSource = myDs.Tables(0)