Advertisement
Guest User

Untitled

a guest
Nov 21st, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Data.SQLite;
  5. using System.Security.Cryptography;
  6. using System;
  7.  
  8. public class GameMode : MonoBehaviour {
  9. private string user;
  10. private string pw;
  11. private string ip;
  12. private string db;
  13. private int port = 3306;
  14. private SQLiteConnection connection;
  15. private void Awake()
  16. {
  17. user = "root";
  18. pw = "";
  19. ip = "31.46.104.228";
  20. db = "test";
  21. string connectionString = string.Format("SERVER={0};DATABASE={1};UID={2};PASSWORD={3};PORT={4}",ip,db,user,pw,port);
  22. connection = new SQLiteConnection(connectionString);
  23. }
  24.  
  25.  
  26. void Start () {
  27.  
  28. string sql = "SELECT * FROM testid";
  29. SQLiteCommand cmd = connection.CreateCommand();
  30. cmd.CommandText = sql;
  31. using (SQLiteDataReader reader = cmd.ExecuteReader())
  32. {
  33. while (reader.Read())
  34. {
  35. Console.WriteLine(reader[0]);
  36. }
  37. }
  38. }
  39.  
  40. void Update () {
  41.  
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement