Guest User

Untitled

a guest
Nov 29th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.UI;
  4. using MySql.Data;
  5. using MySql.Data.MySqlClient;
  6. using System.Collections.Generic;
  7.  
  8. public class ButtonScript : MonoBehaviour {
  9.  
  10. string host = "host=127.0.0.1;port=3306;user=root;password=’root’;database=lab_4";
  11. public void showText(Text outputText) {
  12. MySqlConnection con = new MySqlConnection(host);
  13. MySqlCommand cmd = new MySqlCommand("SELECT * FROM test_table;");
  14.  
  15. cmd.Connection = con;
  16. con.Open();
  17. MySqlDataReader reader = cmd.ExecuteReader();
  18. reader.Read ();
  19. string name = reader["name"].ToString();
  20. cmd.Connection.Close();
  21. cmd.Dispose();
  22. con.Close();
  23.  
  24. outputText.text = name;
  25. }
  26. }
Add Comment
Please, Sign In to add comment