npgsql

Calling a stored procedure in Postgresql through F# and Npgsql

妖精的绣舞 提交于 2019-12-01 18:11:58
I am trying to call a stored procedure in postgresql from F# using the Npgsql type provider. Currently, I am connected to the database as follows: open System open System.Data open System.Data.Entity open System.Data.Linq open Microsoft.FSharp.Data.TypeProviders open Microsoft.FSharp.Linq open Npgsql open NpgsqlTypes type internal dbSchema = SqlEntityConnection<ConnectionString="**my connection string**", Provider="Npgsql"> let internal db = dbSchema.GetDataContext() However, I only see the tables on the db type, not any of the stored procedures. Is there a way to use the stored procedures in

INSERT data from Textbox to Postgres SQL

北战南征 提交于 2019-12-01 18:05:36
I just learn how to connect C# and PostgresSQL. I want to INSERT data from tb1(Textbox) and tb2 to database. But I don't know how to code My previous code is SELECT from database. this is my code private void button1_Click(object sender, EventArgs e) { bool blnfound = false; NpgsqlConnection conn = new NpgsqlConnection("Server=127.0.0.1;Port=5432;User Id=postgres;Password=admin123;Database=Login"); conn.Open(); NpgsqlCommand cmd = new NpgsqlCommand("SELECT * FROM login WHERE name='" + tb1.Text + "' and password = '" + tb2.Text + "'",conn); NpgsqlDataReader dr = cmd.ExecuteReader(); if (dr.Read

INSERT data from Textbox to Postgres SQL

我怕爱的太早我们不能终老 提交于 2019-12-01 18:03:40
问题 I just learn how to connect C# and PostgresSQL. I want to INSERT data from tb1(Textbox) and tb2 to database. But I don't know how to code My previous code is SELECT from database. this is my code private void button1_Click(object sender, EventArgs e) { bool blnfound = false; NpgsqlConnection conn = new NpgsqlConnection("Server=127.0.0.1;Port=5432;User Id=postgres;Password=admin123;Database=Login"); conn.Open(); NpgsqlCommand cmd = new NpgsqlCommand("SELECT * FROM login WHERE name='" + tb1

Why does a query time-out when it is within it's timeout limit?

*爱你&永不变心* 提交于 2019-12-01 13:19:12
I have a long running query that times out after about 48 minutes. The command time-out is set to 2 hours and the connection time-out is set to 17 minutes. What would cause the query to raise a time-out? (I'm assuming there must be something else that I've overlooked?) Npgsql.NpgsqlException: A timeout has occured. If you were establishing a connection, increase Timeout value in ConnectionString. If you were executing a command, increase the CommandTimeout value in ConnectionString or in your NpgsqlCommand object. at Npgsql.NpgsqlState.ProcessBackendResponsesEnum(NpgsqlConnector context) in C:

Why does a query time-out when it is within it's timeout limit?

泪湿孤枕 提交于 2019-12-01 11:54:17
问题 I have a long running query that times out after about 48 minutes. The command time-out is set to 2 hours and the connection time-out is set to 17 minutes. What would cause the query to raise a time-out? (I'm assuming there must be something else that I've overlooked?) Npgsql.NpgsqlException: A timeout has occured. If you were establishing a connection, increase Timeout value in ConnectionString. If you were executing a command, increase the CommandTimeout value in ConnectionString or in your

How to return custom table types from Npgsql and stored procedures?

喜你入骨 提交于 2019-12-01 09:42:01
问题 I'm trying to return a custom (composite) type based on an implicit table type. I have this table definition: CREATE TABLE app_user (id CHAR(36) PRIMARY KEY, name TEXT); Which is mapped to this class definition: public class ApplicationUser { public string Id { get; set; } public string Name { get; set; } } Which is mapped by calling: NpgsqlConnection.MapCompositeGlobally<ApplicationUser>("app_user"); And I'm trying to return a record with this stored procedure: CREATE FUNCTION find_by_id

Postgres Npgsql Connection Pooling

孤人 提交于 2019-12-01 04:32:34
I'd like to better understand Connection Pooling when using Npgsql for Postgres. ( http://www.npgsql.org/ ) When I use the connection string: UserID=root;Password=myPassword;Host=localhost;Port=5432;Database=myDataBase;Pooling=true;Min Pool Size=0;Max Pool Size=100; Where is the "Pooling" going to take place? On my application server or on the database? When I call connection.Open(), what happens? Is a connection taken from the pool if one exists and if not, a pool is created? Any other general info around Connection Pooling would be appreciated. Thanks. Npgsql connection pooling is

Postgres Npgsql Connection Pooling

大憨熊 提交于 2019-12-01 00:27:15
问题 I'd like to better understand Connection Pooling when using Npgsql for Postgres. (http://www.npgsql.org/) When I use the connection string: UserID=root;Password=myPassword;Host=localhost;Port=5432;Database=myDataBase;Pooling=true;Min Pool Size=0;Max Pool Size=100; Where is the "Pooling" going to take place? On my application server or on the database? When I call connection.Open(), what happens? Is a connection taken from the pool if one exists and if not, a pool is created? Any other general

Npgsql integration with Entity Framework Code First

本小妞迷上赌 提交于 2019-11-30 20:26:44
I have a project using the last version of EF CF with PostgreSQL and Npgsql. My model looks like: [Table("mytable")] public class MyTable { [Column("id")] public int Id { get; set; } [Column("mycolumn")] public string MyColumn { get; set; } } And the database/tables/columns has lowercase names like: CREATE TABLE mytable { id serial, mycolumn character(50) } The Npgsql generates SQL commands with quotation marks so I must use the Data Annotations due the PostgreSQL characteristics, witch is annoying. However I would like to not use quotations delimited names in the database. Is there a way to

Can't immediately receive multiple notifications in Npgsql

本小妞迷上赌 提交于 2019-11-30 16:20:13
Today i wrote the following code that works with PostgreSQL C# library named Npgsql: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Npgsql; namespace PostgreSQLNotificationsTest { class Program { static void Main(string[] args) { using (var conn = new NpgsqlConnection("Server=127.0.0.1;Port=5432;User Id=postgres;Password=my_password;Database=helper_db.psql;SyncNotification=true")) { conn.Notification += OnNotification; conn.Open(); using (var command = new NpgsqlCommand("listen notifytest;", conn)) { command