0
I have a little problem, I have a datagridviwer that I fill a table in the database, just before to fill precious take the strokes of the content of the columns. You can use Replace in a datagridviewr column, or some other way to clear the characters and then save to the database.
Follows 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();
}
Has can be used
replace
same, what is the difficulty?– novic
So to tell you the truth I don’t know how to use replace in this code..
– Junior Guerreiro
o . Value is an Object if I am not mistaken, it would be which field?
– novic
Then the value and value of the field inside datagridwier cell 4
– Junior Guerreiro