I have an error with the insert to the Access database, when I run the program and fill in all the fields and I click save it appears that it was saved correctly and does not show any error in the exception, and when I go to see in the database I realize that the saved data does not appear, the Insert I have done it in several ways with querys and with the dataset of vs.
I would like to know why you do not show me the data in Access, and I do not get the error that something is wrong.
This is the code I am using with the query, and I have also done it with the data set and it does not allow me to insert it in Access:
int identificacion = (int) cbIdentificacion.SelectedValue;
int categoria = (int) cbtipoTercero.SelectedValue;
DateTime fecha = DateTime.Today;
String estado = "activo";
try {
//crear conexion
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\andresfelipe\Desktop\Melonada\Melonada\BD\Melonada.accdb");
//conectar a la bd
con.Open();
//query
String sql = "INSERT INTO Tercero VALUES('" + this.txtIdentificacion.Text + "'," + identificacion + ",'" +
this.txtNombre.Text + "','" + this.txtPrimerApellido.Text + "','" + this.txtSegundoApellido.Text + "','" +
this.cbSexo.Text + "','" + this.txtTelefono.Text + "','" + this.txtCelular.Text + "','" + this.txtDireccion.Text + "'," +
categoria + ",'" + fecha + "','" + estado + "');";
OleDbCommand comando = new OleDbCommand(sql, con);
comando.ExecuteNonQuery();
MessageBox.Show("El usuario se ingreso satisfactoriamente");
}
catch(Exception ex) {
MessageBox.Show("no se ingreso" + ex.ToString());
}
// ese es del dataset:
this.terceroTableAdapter1.InsertTercero(this.txtIdentificacion.Text,
identificacion, this.txtNombre.Text, this.txtPrimerApellido.Text,
this.txtSegundoApellido.Text, this.cbSexo.Text, this.txtTelefono.Text,
this.txtCelular.Text, this.txtDireccion.Text, categoria, fecha, estado);