Search Unity

Sql Connector

Discussion in 'Getting Started' started by Laur155, May 2, 2019.

  1. Laur155

    Laur155

    Joined:
    Mar 2, 2017
    Posts:
    30
    Hello there i am trying to use my sql connector to connect to my database.
    I have add the reference MySql.Data but i still getting this error from unity http://prntscr.com/njot9s
    What should i do?
    Thank you!
    Code (CSharp):
    1. using UnityEngine;
    2. using MySql.Data.MySqlClient;
    3.  
    4. public class Test : MonoBehaviour
    5. {
    6.     string db = "server=localhost;" + "uid=root;" + "pwd=;" + "database=test;";
    7.     // Start is called before the first frame update
    8.     void Start()
    9.     {
    10.         try {
    11.             MySqlConnection sq = new MySqlConnection(db);
    12.             sq.Open();
    13.         }catch (Exception er) {
    14.             Debug.Log("Error");
    15.         }
    16.     }
    17.  
    18.     // Update is called once per frame
    19.     void Update()
    20.     {
    21.        
    22.     }
    23. }
    24.