jxbma
asked on
Why do I get an exception when doing a bulk insert into a PostgreSQL DB in my .Net application?
I have a VB .Net application which talks to a backend PostgreSQL database.
I'm using NpgSQL to run queries against that database.
In order to get better performance for bulk inserts into the database, I'm using the PostgreSQLCopyHelper (http://bytefish.de/blog/postgresql_bulk_insert/)
I have used it successfully in other C#/.Net applications.
I have however run into issues when I integrated into my current VB.Net application.
This roughly what my code currently looks like:
I get the following exception when I attempt to do a SaveAll():
HResult -> -2146233079
Message -> "Can't close writer, a row is still in progress, end it first"
With the following stacktrace:
at Npgsql.NpgsqlBinaryImporte r.Close()
at Npgsql.NpgsqlBinaryImporte r.Dispose( )
at PostgreSQLCopyHelper.Postg reSQLCopyH elper`1.Sa veAll(Npgs qlConnecti on connection, IEnumerable`1 entities)
How do I go about debugging this?
Thanks in advance.
I'm using NpgSQL to run queries against that database.
In order to get better performance for bulk inserts into the database, I'm using the PostgreSQLCopyHelper (http://bytefish.de/blog/postgresql_bulk_insert/)
I have used it successfully in other C#/.Net applications.
I have however run into issues when I integrated into my current VB.Net application.
This roughly what my code currently looks like:
Dim copyHelper As PostgreSQLCopyHelper(Of FooClass)
Dim entities As IEnumerable(Of FooClass)
Dim connection As NpgsqlConnection
connection = New NpgsqlConnection(connectionString)
connection.Open()
copyHelper.SaveAll(connection, entities)
I get the following exception when I attempt to do a SaveAll():
HResult -> -2146233079
Message -> "Can't close writer, a row is still in progress, end it first"
With the following stacktrace:
at Npgsql.NpgsqlBinaryImporte
at Npgsql.NpgsqlBinaryImporte
at PostgreSQLCopyHelper.Postg
How do I go about debugging this?
Thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.