SrJefers_Loading

misae

Jun 7th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.14 KB | None | 0 0
  1. String^ encontrado = (textBox1->Text);
  2. String^ conecto = L"datasource=localhost;port=3306;username=root;password=jeferson";
  3. MySqlConnection^ conDataBase = gcnew MySqlConnection(conecto);
  4. MySqlCommand^ cmdDataBase = gcnew MySqlCommand("select * from proyecto_bd.emp_nuevo WHERE emp_id = '" + textBox1->Text + "';", conDataBase); yo lo que hice fue hacer un textbox donde el usurio tiene que agregar el ide y ese ide lo busca entre todo en la base de datos, (emp_id)
  5. MySqlDataReader^ Lectura;
  6. try{
  7. conDataBase->Open();
  8. //cmdDataBase->Parameters->AddWithValue("@emp_id", textBox1->Text);
  9. //AND WHERE emp_id = '"+textBox1->Text+"' emp_id=@emp_id,
  10. Lectura = cmdDataBase->ExecuteReader();
  11. int count = 0;
  12. //label11->Text = textBox1->Text;
  13. //while (Lectura->Read())
  14. //{
  15. // count = count + 1;
  16. //tipo = Lectura->GetString("tipo");
  17. // }//
  18. //if (count == 1){
  19. MessageBox::Show("Encontrado.", "Buscando...", MessageBoxButtons::OK, MessageBoxIcon::Information);
  20. if (Lectura->Read())
  21. {
  22. ------> luego de que encuentra despliego pero convierto todo a tipo string, las variables tipo char no hay problema las pones con getstring pero las que son int las colocas con getint32, y la variable es la que desplegas en el label para que no pueda ser modificado.
  23. String^ emp_idval = Lectura->GetInt32("emp_id").ToString();
  24. label11->Text = emp_idval;
  25. String^ emp_nombreval = Lectura->GetString("emp_nombre");//.ToString()
  26. label12->Text = emp_nombreval;
  27. String^ emp_apellidoval = Lectura->GetString("emp_apellido");
  28. label13->Text = emp_apellidoval;
  29. String^ emp_direccionval = Lectura->GetString("emp_direccion");
  30. label14->Text = emp_direccionval;
  31. String^ emp_dpival = Lectura->GetString("emp_dpi");
  32. label15->Text = emp_dpival;
  33. String^ emp_telefonoval = Lectura->GetString("emp_telefono");
  34. label16->Text = emp_telefonoval;
  35. String^ emp_puestoval = Lectura->GetString("emp_puesto");
  36. label17->Text = emp_puestoval;
  37. String^ emp_fechaingval = Lectura->GetString("emp_fechaing");
  38. label18->Text = emp_fechaingval;
  39. String^ emp_sallival = Lectura->GetDouble("emp_salli").ToString();
  40. label19->Text = emp_sallival;
  41. String^ emp_saltotval = Lectura->GetDouble("emp_saltot").ToString();
  42. label10->Text = emp_saltotval;
  43. }
  44.  
  45. /*}
  46. else if (count>1)
  47. {
  48. MessageBox::Show("ERROR!", "Acceso Denegado", MessageBoxButtons::OK, MessageBoxIcon::Stop);
  49. }
  50. else if (textBox1->Text == "")
  51. {
  52. MessageBox::Show("Deberias de ingresar el ID para poder buscar correctamente el registro...", "Falta algo... :(", MessageBoxButtons::OK, MessageBoxIcon::Stop);
  53. this->textBox1->Focus();
  54. }
  55. else
  56. {
  57. MessageBox::Show("El ID ingresado no ha podido ser encontrado en la base de datos.", "Algo salio mal D:", MessageBoxButtons::OK, MessageBoxIcon::Error);
  58. this->textBox1->Clear();
  59. this->textBox1->Focus();
  60. }*/
  61. }
  62. catch (Exception^ex){
  63.  
  64. MessageBox::Show(ex->Message);
  65. }
Advertisement
Add Comment
Please, Sign In to add comment