Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. public string DisplayValues(string BID)
  2. {
  3. string result = string.Empty;
  4. using (MySqlConnection myCon = new MySqlConnection("datasource = localhost; port = 3306; username = root; password = root"))
  5. {
  6. using (MySqlCommand myCmd = new MySqlCommand("SELECT * FROM table_raw WHERE id = '@value';", myCon))
  7. {
  8. try
  9. {
  10. myCon.Open();
  11. myCmd.Parameters.AddWithValue("@value", BID);
  12. using (MySqlDataReader myRead = myCmd.ExecuteReader())
  13. {
  14. while (myRead.Read())
  15. {
  16. result = myRead.GetString("_VAL").ToString(); //looks for column _VAL where id = the methods input value.
  17. }
  18. myRead.Close();
  19. }
  20. }
  21. catch (MySqlException e)
  22. {
  23. MessageBox.Show(e.ToString());
  24. }
  25. finally
  26. {
  27. myCon.Close();
  28. }
  29. }
  30. }
  31. return result;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement