private void gdr_Click(object sender, EventArgs e)
{
MySqlConnection conexion
= new MySqlConnection
(); MySqlCommand cmd
= new MySqlCommand
(); String cadena;
try
{
cadena = "Server=localhost; uid=root; Database=pbp";
conexion.ConnectionString = cadena;
conexion.Open();
cmd.CommandText = "insert into recep_docs (Edad,APaterno,AMaterno,Nombre,Peticionario,Calle,Colonia,Localidad,Municipio,Telefono,Fecha,Observaciones)Values('" + edad.Text + "','" + apaterno.Text + "','" + amaterno.Text + "','" + nombre.Text + "','" + petic.Text + "','" + calle.Text + "','" + col.Text + "','" + local.Text + "','" + muni.Text + "','" + tel.Text + "','" + fecha.Text + "','" + observa.Text + "')";
cmd.connection=conexion;
cmd.ExecuteNonQuery();
MessageBox.Show("El Registro se ha Hecho Correctamente", "Registros Exitoso");
}
catch
{
MessageBox.Show("Error al conectar la base de Datos", "Conexion Fallida");
}
finally
{
conexion.Close();
}
}
ak te dejo un link
http://vick90.blogspot.es/i2010-05/
Saludos