I'm having a problem, I have a datagridviwer that populates a table in the database, only to fill in the precious points of the contents of the columns. You can use Replace in a datagridviewr column, or some other way to clean the characters and then write to the database.
Follow my code.
public void Inseri()
{
conex1.Open();
SqlCommand cadastro = new SqlCommand("usp_InseriCadastro", conex1);
cadastro.CommandType = CommandType.StoredProcedure;
for (int i = 0; i < dgw_cadastro.Rows.Count -1; i++)
{
cadastro.Parameters.Clear();
cadastro.Parameters.AddWithValue("@NOME",dgw_cadastro.Rows[i].Cells[0].Value);
cadastro.Parameters.AddWithValue("@SOBRENOME",dgw_cadastro.Rows[i].Cells[1].Value);
cadastro.Parameters.AddWithValue("@DDD",Convert.ToInt32(dgw_cadastro.Rows[i].Cells[2].Value));
cadastro.Parameters.AddWithValue("@TELEFONE",Convert.ToInt32(dgw_cadastro. Rows[i].Cells[3].Value));
cadastro.Parameters.AddWithValue("@CPF",dgw_cadastro.Rows[i].Cells[4].Value);
cadastro.Parameters.AddWithValue("@DATANASC",Convert.ToDateTime(dgw_cadastro.Rows[i].Cells[5].Value));
cadastro.ExecuteNonQuery();
}
conex1.Close();
}