Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- C:\Program Files\Unity\Hub\Editor\2018.1.9f2\Editor\Data\Mono\lib\mono\2.0
- Copy Npgsql.dll and System.Data.dll from this directory and put it into Assets/Plugins
- Here is my test function:
- private const String SERVER = "localhost";
- private const String PORT = "5432";
- private const String USER = "postgres";
- private const String PASSWORD = "password";
- private const String DATABASE = "test";
- public NpgsqlConnection connection = null;
- // Use this for initialization
- void Start ()
- {
- connection = new NpgsqlConnection(
- "Server=" + SERVER + ";" +
- "Port=" + PORT + ";" +
- "User Id=" + USER + ";" +
- "Password=" + PASSWORD + ";" +
- "Database=" + DATABASE + ";"
- );
- connection.Open();
- NpgsqlCommand command = new NpgsqlCommand("SELECT name FROM test LIMIT 10", connection);
- // Prepare the command.
- command.Prepare();
- // Execute SQL command.
- NpgsqlDataReader dr = command.ExecuteReader();
- while (dr.Read())
- {
- String TestName = dr.GetString(0);
- Debug.Log("Test Name : " + TestName);
- }
- connection.Close();
- }
Add Comment
Please, Sign In to add comment