Guest User

Untitled

a guest
Dec 12th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. private void button1_Click(object sender, EventArgs e)
  2. {
  3. ConexionDB cnx = new ConexionDB();
  4. textBoxNombre.Text = cnx.Select("clientes",textBoxCodigo.Text);
  5. }
  6.  
  7. public string Select(string strFrom, string strWhere)
  8. {
  9. string query = "SELECT nombre FROM "+strFrom+" WHERE numero ='"+strWhere+"' AND TIPO = 'C'";
  10. string result="";
  11.  
  12.  
  13. if(this.OpenConnection())
  14. {
  15. OdbcCommand cmd = new OdbcCommand(query,conexion);
  16. OdbcDataReader dr = cmd.ExecuteReader();
  17.  
  18. while (dr.Read())
  19. {
  20. result = dr["nombre"].ToString();
  21. }
  22. }
  23.  
  24. this.CloseConnection();
  25.  
  26. return result;
  27. }
  28.  
  29. private void button1_Click(object sender, EventArgs e)
  30. {
  31. ConexionDB cnx = new ConexionDB();
  32. textBoxNombre.Text = cnx.Select("nombre","clientes",textBoxCodigo.Text);
  33. }
  34.  
  35. public string Select(string strSelect, string strFrom, string strWhere)
  36. {
  37. string query = "SELECT "+strSelect+ " FROM "+strFrom+" WHERE numero ='"+strWhere+"' AND TIPO = 'C'";
  38. string result="";
  39.  
  40.  
  41. if(this.OpenConnection())
  42. {
  43. OdbcCommand cmd = new OdbcCommand(query,conexion);
  44. OdbcDataReader dr = cmd.ExecuteReader();
  45.  
  46. while (dr.Read())
  47. {
  48. result = dr["strSelect"].ToString();
  49. }
  50. }
  51.  
  52. this.CloseConnection();
  53.  
  54. return result;
  55. }
  56.  
  57. while (dr.Read())
  58. {
  59. result = dr["strSelect"].ToString();
  60. }
Add Comment
Please, Sign In to add comment