0
//cria conexao com o DB
OleDbConnection aConnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Casa\Desktop\Inventario.mdb");
//comando SQL
OleDbCommand aCommand = new OleDbCommand("INSERT INTO Inventario (CodProd, Qtd, ValorUnit, ValorMerc)" + "Values (@CodProd,Qtd, @ValorUnit, @ValorMerc)", aConnection);
aConnection.Open();
try
{
//percorro o DataGridView
for (int i = 0; i < vGrade.Rows.Count - 1; i++)
{
//limpo os parâmetros
aCommand.Parameters.Clear();
//crio os parâmetro do comando
//e passo as linhas do dgvClientes para eles
//onde a célula indica a coluna do dgv
aCommand.Parameters.AddWithValue("@CodProd",
vGrade.Rows[i].Cells[0].Value);
aCommand.Parameters.AddWithValue("@Qtd",
vGrade.Rows[i].Cells[1].Value);
aCommand.Parameters.AddWithValue("@ValorUnit",
vGrade.Rows[i].Cells[2].Value);
aCommand.Parameters.AddWithValue("@ValorMerc",
vGrade.Rows[i].Cells[3].Value);
//executo o comando
aCommand.ExecuteNonQuery();
}
MessageBox.Show("Concluído");
//fecha a conexao
aConnection.Close();
}
catch (FormatException)
{
MessageBox.Show("Houve um erro");
}
}
How can I implement the progressbar in the above code?
I was using the code below to perform a similar task ( display the progress of the action), but I don’t know how to implement in the above code, what should I do?
try
{
aConnection.Open();
//cria objeto datareader para conexao com a tabela
OleDbDataReader aReader = aCommand.ExecuteReader();
while (aReader.Read())
{
progressBar1.Increment(1);
label1.Text = progressBar1.Value.ToString() + "%";
}
//fecha o reader
aReader.Close();
//fecha a conexao
aConnection.Close();
}
finally { }
}*/
WPF or Windows Forms?
– user26552