Advertisement
Guest User

Untitled

a guest
Mar 18th, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. private void textBox22_TextChanged(object sender, EventArgs e)
  2. {
  3. String path = "Data Source=LOCALHOST; Initial Catalog= sadd; username=root; password=''";
  4. MySqlConnection sqlconn = new MySqlConnection(path); //communicator //constructors
  5. MySqlCommand sqlcomm = new MySqlCommand();
  6. MySqlDataReader sqldr;
  7. sqlconn.Open();
  8. sqlcomm.Connection = sqlconn;
  9. sqlcomm.CommandType = CommandType.Text;
  10. sqlcomm.CommandText = "Select * from approvedrecords where VoucherNumber=" + textBox22.Text + "";
  11.  
  12. sqldr = sqlcomm.ExecuteReader();
  13. sqldr.Read();
  14.  
  15. if (sqldr.HasRows)
  16. {
  17. textBox26.Text = sqldr[0].ToString();
  18.  
  19. }
  20. sqlconn.Close();
  21.  
  22.  
  23. if (textBox22.Text == textBox26.Text)
  24. {
  25.  
  26. String path8 = "Data Source=LOCALHOST; Initial Catalog= sadd; username=root; password=''";
  27. MySqlConnection sqlcon = new MySqlConnection(path8); //communicator //constructors
  28.  
  29. string query = "select * from approvedrecords where VoucherNumber = " + textBox22.Text + " ";
  30. MySqlCommand cmd = new MySqlCommand(query, sqlcon);
  31. MySqlDataReader dbr;
  32.  
  33.  
  34. sqlcon.Open();
  35. dbr = cmd.ExecuteReader();
  36. while (dbr.Read())
  37. {
  38.  
  39. string a = (string)dbr["CheckNumber"].ToString();
  40. string b = (string)dbr["DateCreated"];
  41. string c = (string)dbr["Status"];
  42. string d = (string)dbr["PayeesName"];
  43. string f = (string)dbr["Amount"].ToString();
  44. string g = (string)dbr["DatePrinted"];
  45. string h = (string)dbr["Particulars"];
  46. string i = (string)dbr["Prepared_by"];
  47. string j = (string)dbr["Payment_received_by"];
  48.  
  49. textBox21.Text = a;
  50. textBox23.Text = b;
  51. textBox28.Text = c;
  52. textBox20.Text = d;
  53. textBox19.Text = f;
  54. textBox27.Text = g;
  55. textBox18.Text = h;
  56. textBox16.Text = i;
  57. textBox17.Text = j;
  58.  
  59. }
  60. }
  61. else
  62. {
  63. MessageBox.Show("ID doesn't exist!");
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement