Connection c # with postgresql

1

They could help me with my connection to register data

private void btnAgregar_Click(object sender, EventArgs e)
{
        try
        {
            NpgsqlConnection cn = new  NpgsqlConnection("DRIVER={PostgreSQL ANSI};" + "SERVER=localhost;" + "UID=postgres;" + "PWD=damaris;" + "DATABASE=ProyectoAsistenciaCCB;");
            cn.Open();
            NpgsqlCommand query = new  NpgsqlCommand("INSERT INTO miembros (nombre,apellidos,sexo,grupo,fecha_nacimiento,domicilio,fecha_bautismo,fecha_espiritusanto,status)" + "VALUES ('" + txtNombre.Text + "','" + txtApellidos.Text + "','" + txtSexo.Text + "','" + txtGrupo.Text + "' ,'" + txtNacimiento.Text + "' ,'" + txtDomicilio.Text + "' ,'" + txtBautismo.Text + "','" + txtEspiritu.Text + "','" + txtStatus.Text + "')", cn);
            query.ExecuteNonQuery();
            cn.Close();
            cn.Dispose();
            MessageBox.Show("Miembro registrado exitosamente");

    }
}
    
asked by karol 17.10.2016 в 19:35
source

1 answer

2

If your problem is the connection string, try this:

NpgsqlConnection cn= new NpgsqlConnection("Server=127.0.0.1;Port=5432; User Id=postgres;Password=damaris;Database = ProyectoAsistenciaCCB;TIMEOUT=15;POOLING=True;MINPOOLSIZE=1;MAXPOOLSIZE=20;COMMANDTIMEOUT=20");
    
answered by 17.10.2016 / 19:46
source