• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • 💡 We're thrilled to announce that our upcoming texturing contest is in the works, and we're eager to hear your suggestions! Please take this opportunity to share your ideas in this theme discussion thread for the Texturing Contest #34!
  • 🏆 Hive's 7th HD Modeling Contest: Icecrown Creature is now open! The frozen wastes of Icecrown are home to some of Azeroth’s most terrifying and resilient creatures. For this contest, your challenge is to design and model a HD 3D monster that embodies the cold, undead, and sinister essence of Icecrown! 📅 Submissions close on April 13, 2025. Don't miss this opportunity to let your creativity shine! Enter now and show us your frozen masterpiece! 🔗 Click here to enter!

[Advanced Tutorial] MySQL

Status
Not open for further replies.
To start using MySQL within Unity (a server built in unity), you need the MySQL connector.

http://dev.mysql.com/downloads/connector/net/1.0.html#downloads

After the installation, navigate to the installation directory, Assemblies, v2.0, then grab the MySql.data.dll and place it in your Project's plugin folder (if it doesn't exist, create it).

Code:
//First line
import MySql.Data.MySqlClient;
(We import the library)

Now, we need several things.
Let us make a Start() function.

Code:
function Start(){}
Let us think for a second.
We want the server to open up a connection and pass commands.
Alright then.


Code:
function Start(){
var connection = new MySqlConnection("SERVER=SERVERIPGOESHERE;DATABASE=the database you want;UID=username;PASSWORD=repwh***;");
//Basically, we declared the connection we want. You could, of course, make that several strings and change them at will.
}
Connection is set up.

Code:
function Start(){
var connection = new MySqlConnection("SERVER=SERVERIPGOESHERE;DATABASE=the database you want;UID=username;PASSWORD=repwh***;");
//Basically, we declared the connection we want. You could, of course, make that several strings and change them at will.


//Alright.
connection.Open(); // Opens up the connection

//We pull up a command
    var dbcmd : MySqlCommand = MySqlCommand("INSERT BLAH BLAH BLAH", connection);
//And we execute it
    var reader : MySqlDataReader = dbcmd.ExecuteReader();

}
Now, if you want to close a connection, just do a connection.Close();


I am willing to help you out, if you don't get it working by following this tutorial.

TROUBLESHOOTING:

If you are having any errors, change your api compatibility to .net 2 instead of .net 2 subset @ player settings.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,273
You network it so that the Client asks the server, and the server performs the queries, silly DSG.
And what stops a client sending out queries to destroy tables? Make new tables? Flood tables? Access data from tables it should not? Or are you trying to say that the client performs remote procedure/function calls that then the server makes and performs the queries?
 
Status
Not open for further replies.
Top