How to connect to the PostgreSql database using Xamarim

0

To create a Mobile application using the PostgreSql database, but not able to open the connection:

My code:

public class PgSql
{
    private string connString = "Server=192.168.1.5;Port=5432;User ID=postgres;Password=Kalisba987;Database=LotusERP;";
    private NpgsqlConnection conn;

    public string connect()
    {
        Thread thread = new Thread();
        thread.Start();
        string retorno;
        conn = new NpgsqlConnection(connString);
        try
        {
            this.conn.Open();
            retorno = "Conexão aberta com o banco PostgreSql";
        }
        catch (NpgsqlException ex)
        {
            retorno = ex.Message;
        }
        finally
        {
            this.conn.Close();
        }
        return retorno;
    }
}

The error every time on the line

conn = new NpgsqlConnection(connString);

And the following message appears:

  

Unhandled Exception:   System.TypeInitializationException: The type initializer for 'System.Collections.Generic.List'1' threw an exception

    
asked by anonymous 25.07.2017 / 21:09

0 answers