0
I have a datagridviwer populated by a query of the sql database, in this datagrid I have a column with a chekbox, now comes my doubt, as I write to the database when the line has been selected by the user in chekbox.
code today where I do the Insert in the bank but without chekbox working
private void ncheklist()
{
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = @"INSERT INTO TBL_CHEKLIST (N_NOTA, CLIENTE, TRANSP, VOLUME, N_CHEKLIST, EMISSAO)
VALUES (@NOTA, @CLIENTE, @TRANSP, @VOLUME, @CHEKLIST, @EMISSAO)";
cmd.Connection = conex1;
conex1.Open();
cmd.Parameters.Add(new SqlParameter("@NOTA", this.txt_nota.Text));
cmd.Parameters.Add(new SqlParameter("@CLIENTE", this.txt_cliente.Text));
cmd.Parameters.Add(new SqlParameter("@TRANSP", this.txt_transp.Text));
cmd.Parameters.Add(new SqlParameter("@VOLUME", this.txt_volume.Text));
cmd.Parameters.Add(new SqlParameter("@CHEKLIST", this.txt_nchklist.Text));
cmd.Parameters.Add(new SqlParameter("@EMISSAO", Convert.ToDateTime(txt_dtinicial.Text).ToString("yyyy/MM/dd").Replace("/", "")));
cmd.ExecuteNonQuery();
conex1.Close();
}
vnbrs, thanks for editing, where I click to edit to c# usually put between the tags "code".
– Agnaldo
Thank you so much for your attention, I tested it here and it worked, I just couldn’t do take the value of the columns and do the Insert, I mean I couldn’t do for hi command take the value of each cell and do the Insert in the database in the correct fields.
– Junior Guerreiro
Forget the above comment, I set the code here and it worked the Internet thank you very much.
– Junior Guerreiro
Junior Warrior, I’m glad you could work it out, Hug.
– Agnaldo