Hello folks,

I am seeing a weird InvalidOperationException being thrown when I use a (Npgsql)DataAdapter's update method in a particular setting. As I'm unsure where the error lies, I'm looking for help here before filing any bugs.

Part of the problem might be that my db related stuff is coded against the generic interfaces for the sake of db engine independence. The error itself occurs on mono (1.1.7 in my case), regardless of whether used on Windows or Linux, when using Npgsql as the database provider. It does not occur on Windows with MS's framework 1.1 and Npgsql. It does also not occur on mono/MS.NET with their respective System.Data.SqlClient implementations.

Now here goes... The unrelated parts of an example program are left out. The following expects a connection "conn" to opened to a certain database with a table "table1" with an id, col1 of type varchar(50) and col2 of type integer.

           //Write back changes into database
IDbCommand cmdUpdate = new NpgsqlCommand("UPDATE table1 SET col1=:p1, col2=:p2 WHERE id=" + id.ToString()); cmdUpdate.Parameters.Add( new NpgsqlParameter("p1", NpgsqlTypes.NpgsqlDbType.Varchar, 0, "col1") ); cmdUpdate.Parameters.Add( new NpgsqlParameter("p2", NpgsqlTypes.NpgsqlDbType.Integer, 0, "col2") );
           cmdUpdate.Connection = conn;
da = new NpgsqlDataAdapter();
           da.UpdateCommand = cmdUpdate;
           da.TableMappings.Add("Table", "table1");
           int affectedRows = da.Update( ds );

The error that is raised on the Update command is the following:
Unhandled Exception: System.InvalidOperationException: Cannot read data. No result set.
in <0x0003c> Npgsql.NpgsqlDataReader:CheckHaveResultSet ()
in <0x00028> Npgsql.NpgsqlDataReader:Read ()
in <0x00777> System.Data.Common.DbDataAdapter:Update (System.Data.DataRow[] dataRows, System.Data.Common.DataTableMapping tableMapping)

I surely appreciate any hint to where the source of the problem can be found ;-) For the records, Windows is XP/SP2, Linux is an older SuSE 9.1 with mono compiled from source.

Best regards,
Helge

_______________________________________________
Mono-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to