I’m trying to connect to a MySQL database through a C# script. I’ve tested my code in another program and know that it works fine. However, unity claims I am missing an assembly reference.
At the moment, all my code does is connect to my database as follows:
using UnityEngine;
using System;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
public class DataBaseTest : MonoBehaviour
{
string name = "Herp Derp";
int score = 325;
SqlConnection _connection;
// Use this for initialization
void Start ()
{
_connection = new SqlConnection("Data Source=localhost\\SQLEXPRESS; Database=SQLExpress\\Darkride; Initial Catalog=Darkride; Trusted_Connection=True");
}
}
I’ve added in the references to System.Data and System.Data.DataSetExtensions to my visual studio as well.
However, when I go back to Unity I get the following error:
Assets/DataBaseTest.cs(5,14): error CS0234: The type or namespace name
Data' does not exist in the namespaceSystem’. Are you missing an assembly reference?
As far as I can tell, I’ve added in my reference correctly. I’ve googled for the past few hours trying to find a fix and some people suggested that you change from using .Net 2.0 subset to using .Net 2.0. But that hasn’t worked and I’m still getting the issue.
Does anyone know how I can beat this issue?