npgsql

Why this NpgsqlDataAdapter.Update command always return 1?

I want to make my program robust by putting concurrency check, but somehow UpdateCommand fails me even in the most basic update sql. Using Npgsql 2.0.2 var dax = new NpgsqlDataAdapter(); using (var dtStore = delta.Tables["brand"].GetChanges(DataRowState.Modified)) if (dtStore != null) { dax.UpdateCommand = new NpgsqlCommand( @"upda...

Where (or how) should I define the schema in a select statement when using PostgreSQL?

I have an application built upon ASP.NET 3.5 and PostgreSQL 8.3. My database has 3 users, a data owner (xxx-owner), a data editor (xxx-editor), and a data viewer (xxx-viewer). Each user has their own schema called xxx-schema, xxx-editor-schema and xxx-viewer-schema. All the data is stored in xxx-schema. This requires that I specify t...

Npgsql & Postgresql : ERROR: XX001: could not read block 2354 of relation...

Hi, I have a service running and inserting data (a lot of data). Sometime, and this is only about few weeks, I receive this error: ERROR: XX001: could not read block 2354 of relation 1663/17633/17925: read only 0 of 8192 bytes. This error is from the Npgsql connector of PostGresql: Exception trace: at Npgsql.NpgsqlConnector.Chec...

Updated Npgsql(1.0 -> 2.05) and got error (ObjectNotFoundException) on NHIbernate

Hello Guys... I updated the Npgsql driver to the last version (2.0.5) and got error in my NHibernate App... Mappings: School mapping : ... References(x => x.City); ... And City Mapping: Id(x => x.ID).GeneratedBy.Assigned(); Map(x => x.Name); References(x => x.Microrregion); Now, when I tried to load a School, I got a NHibernate....

How to map(NHibernate) a specified PostgreSql type ?

Hello guys... I have a PK (character (10)), that is mapped like that: The load works fine with npgsql 1.0, the sql generated with loadbyid is : SELECT city0_."IDCity" as IDMu1_92_0_ FROM "tblCity" city0_ WHERE city0_."IDCity"=E'BR420240' Using npgsql 2.0. the sql generated is : SELECT city0_."IDCity" as IDMu1_92_0_ FROM "tb...

Npgsql reader type cast error (was: mono does not serialize complex types well)

Hi, Am I right that serializing complex types is not implemented in Mono 2.4.2 yet, or have I made a mistake? When I call my remote function, I get an error message: Cannot cast from source type to destination type. at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke (System.Runtime.Remoting.Proxies.RealProxy rp, IMessa...

How can I provide the table name for a query as command parameter in Npgsql?

I want to provide the table name for a query as command parameters, like so: public class Foo { private const String myTableName = "mytable"; public void Bar() { NpgsqlCommand command = new NpgsqlCommand("SELECT * from :tableName", connection); command.Parameters.Add(new NpgsqlParameter("tableName", DbType.S...

Using npgsql to call a function that takes character as parameter

I am trying to use Npgsql to invoke a function (stored procedure) that takes a CHARACTER as parameter, but it doesn't work. If I declare the same function without parameters, or with an INTEGER parameter, I get the result sets that I want. When I declare the parameter as CHARACTER, it stops working. What is wrong? Here is the code of my...

NHibernate, Npgsql, and the inet type

Hello, I'm writing a web application using ASP.net MVC, NPgsql and NHibernate with PostgreSQL as the database (using VB... not my choice). One of the tables has two columns with an inet type. In the mapping file, I tried mapping it as a string. This actually worked fine until I had to update a row. I get an error message: "column "myc...

Using npgsql with SSIS

Hi, I am using npgsql as the ADO.NET provider in SSIS to connect to Postgres and create some workflows. I am able to connect to postgres but am unable to use the "Table or view" data access mode to list the tables and views. I have to resort to using "SQL command" data access mode. For the "table or view" access mode, the log shows tha...

NPGSQL: Streaming results from Postgres query?

Hi. I have a large table (2,000,000 rows) and I'd like to print each record to the screen, one at time, without loading the entire table into memory. //pseudo code var cmd = new NpgSQLCommand(); cmd.CommandText = "SELECT * FROM mytable;" IReader reader = cmd.ExecuteReader(); //blocks until the entire set is returned while(reader.Read(...

NpgSQLdataReader GetOrdinal throwing exceptions.. any way around?

I built a wrapper around NpgSQL for a bunch of the methods I usually use in my projects' DAL. Two of them, I usually use to fill DTOs straight from a DataReader. Usually in a fill helper method, i'll instanciate the DTO and iterate through the properties mapping the Datareader's data to the corresponding property. The fill method is gene...

Npgsql pass parameters by name to a stored function

I'm working with code I'm converting to Pgsql working with .NET. I want to call a stored function that has several parameters, but I'd like to bind the parameters by name, like so: NpgsqlCommand command = new NpgsqlCommand("\"StoredFunction\"", _Connection) command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("para...

Postgres with Npgsql get periodical error-message every 5 hours

We have an application utilizing NHibernate 2.1.2, Npgsql 2.0.8 and PostgreSQL 8.3.7. We notice that the connection-pool for our application gets trashed at regular time-intervals in our production-enviroment, not occasionally but every 5 hours. When looking at the logfile for postgres, we see this: 2010-03-08 00:02:02 CET LOG: inco...

Unit Test For NpgsqlCommand With Rhino Mocks

My unit test keeps getting the following error: "System.InvalidOperationException: The Connection is not open." The Test [TestFixture] public class Test { [Test] public void Test1() { NpgsqlConnection connection = MockRepository.GenerateStub<NpgsqlConnection>(); // Tried to fake the open connection c...

NpgSQL insert file path containing backslashes "\\"

I am trying to create a record containing the path to a file. The insertion is done into a Postgres database where UTF8 is enabled, using the NpqSQL driver. My table definition: CREATE TABLE images ( id serial, file_location character varying NOT NULL ) My SQL statement including the code that executes it (boiled down to a mi...

C# and NpgsqlDataAdapter returning a single string instead of a data table

I have a postgresql db and a C# application to access it. I'm having a strange error with values I return from a NpgsqlDataAdapter.Fill command into a DataSet. I've got this code: NpgsqlCommand n = new NpgsqlCommand(); n.Connection = connector; // a class member NpgsqlConnection DataSet ds = new DataSet(); DataTable dt = new DataTabl...

Can I use Npgsql Data Provider in my .NET 4.0 project?

I have an MVC project that I would like to write in .NET 4.0 Is it possible to use Npgsql (which currently supports .net 3.5 ) if I will use it through Entity Framework, and I will limit myself to features of EF contained within 3.5? ...

npgsql Leaking Postgres DB Connections: Way to monitor connections?

Background: I'm moving my application from npgsql v1 to npgsql v2.0.9. After a few minutes of running my application, I get a System.Exception: Timeout while getting a connection from the pool. The web claims that this is due to leaking connections (opening a db connection, but not properly closing them). So I'm trying to diagnose lea...

How to solve ProviderManifestToken="8.3.7" and Npgsql ProviderManifestToken="8.1.3" conflict?

I'm trying to connect to my PostgreSQL database using Entity Framework. Unfortunately after generating a model using EdmGen (or EdmGen2) in my SSDL file ProviderManifestToken is set to 8.3.7 when in the current version of Npgsql (2.0.9) it is set to 8.1.3. This gives me fallowing exception when trying to use my entity model: System.D...