Hi everybody,
I’m looking for something simple, using databases with javascript, i have seen a lot of things about System.Data.dll missing (my case) and Mysql.Data.dll missing (same) but I put the script in the asset folder and in the editor folder too but no result.
Is there a simple way to do it?
Or is it only possible with C# (tried but I have some errors).
PS: I have the pro version.
PS 2 : Ok I just took everything out of the asset directory now when I try to connect, it gives me :
System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP, Boolean requireSocketPolicy)
What database are you trying to connect to?
MySql is generally a web style database. Perhaps using PHP or ASP to roll the data back into Unity is a better solution.
Mysql.
The code :
import System.Data.SqlClient;
function Start () {
var dbcon : IDbConnection;
var connectionString : String = "Server=localhost;" + // put the ip here!
"Database=supermarket;" +
"User ID=test;" +
"Password=test;";
dbcon = new SqlConnection(connectionString);
dbcon.Open();
//create the class EXECUTIONER, that execute SQL commands
var dbcmd : IDbCommand = dbcon .CreateCommand();
//string var, to save the command we want to use
var cmdSql : String = "SELECT * FROM telephone";
//we add the command, as string, to the executor, to shot it!
dbcmd.CommandText = cmdSql;
//and then, we create a table, like a normal db table, to use it on unity, and we use the function that "plays" the command
var reader : IDataReader = dbcmd.ExecuteReader();
while(reader.Read()) {
var id : String = reader.GetString(0);
/* var nome : String = reader ["[COLOR="#2e8b57"]nmUsuario[/COLOR]"].ToString();
var login : String = reader ["[COLOR="#2e8b57"]dsLogin[/COLOR]"].ToString();
var senha : String = reader ["[COLOR="#2e8b57"]dsSenha[/COLOR]"].ToString();
print ("ID: " + id + "NAME: " + nome + "LOGIN: " + login + "PASSWORD: " + senha);*/
Debug.Log(id);
}
reader.Close();
reader = null;
dbcmd.Dispose();
dbcmd = null;
dbcon.Close();
dbcon = null;
}
Using php to go to mysql isn’t the most easy way to maintain code since my code will be used by other people, it would be more logical to use directly Mysql.
Moreover people can do it this way :
http://forum.unity3d.com/threads/28500-SQLite-Class-Easier-Database-Stuff
Can u tell in detail how to roll back in unity
I have :
SocketException: Aucune connexion n’a pu être établie car l’ordinateur cible l’a expressément refusée.
System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP, Boolean requireSocketPolicy)
System.Net.Sockets.Socket+Worker.Connect ()
Rethrow as TdsInternalException: Server does not exist or connection refused.
Mono.Data.Tds.Protocol.TdsComm…ctor (System.String dataSource, Int32 port, Int32 packetSize, Int32 timeout, TdsVersion tdsVersion)
Mono.Data.Tds.Protocol.Tds…ctor (System.String dataSource, Int32 port, Int32 packetSize, Int32 timeout, TdsVersion tdsVersion)
Mono.Data.Tds.Protocol.Tds70…ctor (System.String server, Int32 port, Int32 packetSize, Int32 timeout, TdsVersion version)
Mono.Data.Tds.Protocol.Tds80…ctor (System.String server, Int32 port, Int32 packetSize, Int32 timeout)
Mono.Data.Tds.Protocol.TdsConnectionPoolManager.CreateConnection (Mono.Data.Tds.Protocol.TdsConnectionInfo info)
Mono.Data.Tds.Protocol.TdsConnectionPool.GetConnection ()
System.Data.SqlClient.SqlConnection.Open ()
Rethrow as SqlException: Server does not exist or connection refused.
System.Data.SqlClient.SqlConnection.Open ()
DatabaseHandler.Start () (at Assets/DatabaseHandler.js:14)
When It comes to the open function.