Ver Mensaje Individual
  #6 (permalink)  
Antiguo 27/03/2010, 14:21
rikimm
 
Fecha de Ingreso: agosto-2008
Ubicación: D,F
Mensajes: 412
Antigüedad: 15 años, 8 meses
Puntos: 4
Respuesta: problema con inster y duda con update

DarkWatch

gracias por tu ayuda bueno pongo el codigo para que vean como quedo y para que les ayude a otros en caso de que tenga el mismo problema lo unico que hise fue crear otra variable Sql2 para que no hubiera confucion y solo cree otro(Com.CommandText = Sql2;
x = Com.ExecuteNonQuery();) para que fuera mas en orden:
Código C#:
Ver original
  1. OleDbConnection BaseDatos = new OleDbConnection();
  2.             OleDbCommand Com = new OleDbCommand();
  3.             string Sql,Sql2;
  4.             int x;
  5.            
  6.  
  7.             BaseDatos.ConnectionString = @"PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\doggy_park.mdb";
  8.             BaseDatos.Open();
  9.             Com.Connection = BaseDatos;
  10.             Com.CommandType = CommandType.Text;
  11.             Sql = "INSERT INTO Cliente ( nombre, apellido,direccion, mail, mascota, raza, color, señas, fecha_entra, fecha_sale, edad, M, F,tipo_mascota,otro,letra,telefono)";
  12.             Sql = Sql + "SELECT '" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text + "','" + textBox9.Text + "','" + textBox1.Text + "','" + dateTimePicker1.Text + "','" + dateTimePicker2.Text + "','" + comboBox1.Text + "','" + radioButton1.Checked + "','" + radioButton2.Checked + "','" + checkBox1.Tag + "','" + richTextBox1.Text + "','" + miLetra + "'," + textBox5.Text + ";";
  13.                            
  14.             Com.CommandText = Sql;
  15.             x = Com.ExecuteNonQuery();
  16.  
  17.             Sql2 = "INSERT INTO comportamiento(mascota,dueno,num)";
  18.             Sql2 = Sql2 + "SELECT '" + textBox2.Text + "','" + textBox7.Text + "'," + textBox5.Text + ";";
  19.  
  20.             Com.CommandText = Sql2;
  21.             x = Com.ExecuteNonQuery();
  22. BaseDatos.Close();

ahora en el asunto del update tengo este problema me manda el siguente error "no se han especificado valores para algunos de los parametros requeridos"

este es el codigo que manejo:
Código C#:
Ver original
  1. OleDbConnection BaseDatos = new OleDbConnection();
  2.             OleDbCommand Com = new OleDbCommand();
  3.             string Sql;
  4.             int x;
  5.  
  6.  
  7.             BaseDatos.ConnectionString = @"PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\doggy_park.mdb";
  8.             BaseDatos.Open();
  9.             Com.Connection = BaseDatos;
  10.             Com.CommandType = CommandType.Text;
  11.  
  12.             Sql = "UPDATE [Cliente] set [nombre] = " + textBox2.Text + ", apellido = " + textBox3.Text + " ,telefono=" + textBox5.Text + " where [id] = "+textBox1.Text+";";
  13.             Com.CommandText = Sql;
  14.             x = Com.ExecuteNonQuery();
  15.             if (x > 0)
  16.             {
  17.  
  18.  
  19.  
  20.                 MessageBox.Show("SE HAN GUARDADO LOS REGISTROS EN LA BASE DE DATOS", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
  21.                 textBox2.Clear();
  22.                 textBox3.Clear();
  23.                 textBox5.Clear();
  24.                
  25.             }
  26.             else
  27.             {
  28.                 MessageBox.Show("NO SE HAN PODIDO GUARDAR LOS REGISTROS EN LA BASE DE DATOS FAVOR DE LLENAR EL SIGUIENTE CAMPO: TELEFONO", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  29.             }
__________________
Si el amor a una mujer es igual al amor a la programacion
cual de las dos escojerias...mmmm buena pregunta jejeje

Última edición por rikimm; 27/03/2010 a las 14:52 Razón: poner otro codigo que me da error en el update