So I’m trying to make buttons that changes values in MySQL. This is what I have so far and I hope someone give me point what to add or change.
using UnityEngine;
using System.Collections;
using System.Data;
using MySql.Data.MySqlClient;
public class Stats : MonoBehaviour {
string connectionString =
“Server=localhost;” +
“Database=buttontest;” +
“User=root;” +
“Password=root;” +
“Pooling=false”;
IDbConnection dbcon;
dbcon = new MySqlConnection(connectionString);
dbcon.Open();
IDbCommand dbcmd = dbcon.CreateCommand();
void OnGUI(){
if(GUI.Button(new Rect(20,40,80,20), “-”)) {
UPDATE stats SET anw = anw - 1 WHERE stats_id = uid;
}
if(GUI.Button(new Rect(20,40,80,20), “+”)) {
UPDATE stats SET anw = anw + 1 WHERE stats_id = uid;
}
}
}