using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MySql.Data.MySqlClient;
using UnityEngine.UI;
public class dbControl : MonoBehaviour {
string database_connection = "server" + "uid=;" + "pwd=;" + "database=;";
public Text nick;
public Text password;
public GameObject menu;
public void connect()
{
MySqlConnection connection = new MySqlConnection(database_connection);
connection.Open();
connection->query("SELECT * FROM login WHERE nick='nick' AND password='password'");
if (connection->query("SELECT * FROM login WHERE nick='nick' AND password='password'")->num_rows > 0)
{
menu.SetActive(true);
connection->Close();
}
}
}
Tak wygląda skrypt, który miał połączyć się do bazy i wysłać zapytanie o spójności wpisanego nicku i hasła.
Errory:
Assets/dbControl.cs(18,9): error CS0012: The type `System.Data.Common.DbConnection' is defined in an assembly that is not referenced. Consider adding a reference to assembly `System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Assets/dbControl.cs(21,19): error CS0214: Pointers and fixed size buffers may only be used in an unsafe context
Assets/dbControl.cs(21,19): error CS0193: The * or -> operator must be applied to a pointer
Assets/dbControl.cs(22,23): error CS0214: Pointers and fixed size buffers may only be used in an unsafe context
Assets/dbControl.cs(22,23): error CS0193: The * or -> operator must be applied to a pointer
Assets/dbControl.cs(25,23): error CS0214: Pointers and fixed size buffers may only be used in an unsafe context
Assets/dbControl.cs(25,23): error CS0193: The * or -> operator must be applied to a pointer