[Mono-bugs] [Bug 522624] New: SQL Data Adatper issues with NULL columns

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Jul 16 06:32:28 EDT 2009


           Summary: SQL Data Adatper issues with NULL columns
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.4.x
          Platform: x86
        OS/Version: Windows Vista
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Sys.Data
        AssignedTo: bnc-blr-team-mono at forge.provo.novell.com
        ReportedBy: jxelam at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---

Created an attachment (id=305496)
 --> (http://bugzilla.novell.com/attachment.cgi?id=305496)
SQLite database required for reproduction of the issue

Description of Problem:

Using a data adapter Fill() and Update() on a table with columns where nulls
are enabled causes problems. 

For example, under SQL Server writing to a date time field that can be null
causes ICOnvertible errors, trying to cast it to an Int32. Concurrency errors
are also given when writing an integer to an int column that allows NULL and
also currently contains the NULL value.

These issues seem haphazard to reproduce on some machines, though the attached
fail case seems to always fail, and be related to the others.

Steps to reproduce the problem:
1. Compile and the follow program (gmcs -r:System.Data -r:Mono.Data.Sqlite
2. Put the attached SQLite database in the same directory
3. Put sqlite3 library in same folder (e.g sqlite3.dll on Windows)
3. Run the compiled program

using System;
using System.Data;
using Mono.Data.Sqlite;

class Program
    private static string DB_CONN = "Data Source=|DataDirectory|SqliteTest.db";

    static void Main(string[] args)
        IDbConnection conn = new SqliteConnection(DB_CONN);
        DataSet ds = new DataSet();


        IDbCommand command  = conn.CreateCommand();
        command.CommandText = "SELECT * FROM testtable";

        SqliteDataAdapter    adapter = new
        SqliteCommandBuilder builder = new SqliteCommandBuilder(adapter);


        ds.Tables[0].TableName = "testtable";
        adapter.UpdateCommand = (SqliteCommand)builder.GetUpdateCommand(true);
// mono workaround

        ds.Tables[0].Rows[0]["testInt"] = 5;
        adapter.Update(ds, "testtable");

Actual Results:

Unhandled Exception: System.Data.DBConcurrencyException: Concurrency violation:
the UpdateCommand affected 0 records.
  at System.Data.Common.DbDataAdapter.Update (System.Data.DataRow[] dataRows,
stem.Data.Common.DataTableMapping tableMapping) [0x00000]

Expected Results:

No error, integer value of 5 should be written to column testInt in row with id

How often does this happen? 


Additional Information:

The table (TestTable) just contains two columns. The first is id (int) set to
PK, the second is testInt (int) nulls allowed. There is one row, with id 1 and
testInt set to NULL.

The issue is only present if testInt contains NULL before Fill() and Update()

As stated earlier, this is merely a fully reproducible test case, I believe the
cause is more fundamental, affecting at least SQL Server as well (the same test
on that causes the same exception).

A full description and analysis of the original issue can be found at:
which uses SqlDataAdapter, though it was found not to be reproducible by some

Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the mono-bugs mailing list