Advertisement
SrJefers_Loading

buscar

Jun 8th, 2016
10,250
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 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);
  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. MessageBox::Show("Encontrado.", "Buscando...", MessageBoxButtons::OK, MessageBoxIcon::Information);
  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. else
  45. {
  46. MessageBox::Show("Registro no encontrado.", "Buscando...", MessageBoxButtons::OK, MessageBoxIcon::Information);
  47.  
  48. }
  49.  
  50. /*}
  51. else if (count>1)
  52. {
  53. MessageBox::Show("ERROR!", "Acceso Denegado", MessageBoxButtons::OK, MessageBoxIcon::Stop);
  54. }
  55. else if (textBox1->Text == "")
  56. {
  57. MessageBox::Show("Deberias de ingresar el ID para poder buscar correctamente el registro...", "Falta algo... :(", MessageBoxButtons::OK, MessageBoxIcon::Stop);
  58. this->textBox1->Focus();
  59. }
  60. else
  61. {
  62. MessageBox::Show("El ID ingresado no ha podido ser encontrado en la base de datos.", "Algo salio mal D:", MessageBoxButtons::OK, MessageBoxIcon::Error);
  63. this->textBox1->Clear();
  64. this->textBox1->Focus();
  65. }*/
  66. }
  67. catch (Exception^ex){
  68.  
  69. MessageBox::Show(ex->Message);
  70. }
  71.  
  72. conDataBase->Close();
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement