Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public string DisplayValues(string BID)
- {
- string result = string.Empty;
- using (MySqlConnection myCon = new MySqlConnection("datasource = localhost; port = 3306; username = root; password = root"))
- {
- using (MySqlCommand myCmd = new MySqlCommand("SELECT * FROM table_raw WHERE id = '@value';", myCon))
- {
- try
- {
- myCon.Open();
- myCmd.Parameters.AddWithValue("@value", BID);
- using (MySqlDataReader myRead = myCmd.ExecuteReader())
- {
- while (myRead.Read())
- {
- result = myRead.GetString("_VAL").ToString(); //looks for column _VAL where id = the methods input value.
- }
- myRead.Close();
- }
- }
- catch (MySqlException e)
- {
- MessageBox.Show(e.ToString());
- }
- finally
- {
- myCon.Close();
- }
- }
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement