[Mono-bugs] [Bug 385029] New: Multple errors using Mysql Connector and DbCommandBuilder

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Apr 29 18:55:12 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=385029


           Summary: Multple errors using Mysql Connector and
                    DbCommandBuilder
           Product: Mono: Class Libraries
           Version: 1.9.0
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Sys.Data
        AssignedTo: bnc-blr-team-mono at forge.provo.novell.com
        ReportedBy: tedu at fogcreek.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


This is a simple test program.  It should work, but throws multiple exceptions.

It requires a MySql database, you can change the connection string as needed.

Initial setup:
create table Mono (Num int primary key, word char(10) default 'pickle' not
null, syn char(10) );
insert into Mono Values (0, "hello", NULL);

The first test finds two bugs when performing updates.
The second test finds a bug where default values are not used.

Everything works with .NET.


using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using MySql.Data.MySqlClient;

static class TestMonoDB {
        static string connectionString =
"Server=10.0.0.1;Database=monotest;user id=Mono;password=Mono;";

        static void test1() {
                using (MySqlConnection db = new
MySqlConnection(connectionString)) {
                        db.Open();
                        string sql = "Select * From Mono;";

                        DataSet ds = new DataSet();

                        MySqlCommand cmd = new MySqlCommand(sql);
                        cmd.Connection = db;
                        MySqlDataAdapter da = new MySqlDataAdapter(cmd);

                        da.Fill(ds);

                        MySqlCommandBuilder builder = new
MySqlCommandBuilder(da);

                        DataRow row = ds.Tables[0].Rows[0];

                        row[1] = "bam";
                        builder.DataAdapter.Update(new DataRow[] { row } );

                        db.Close();
                }
        }
        static void test2() {
                using (MySqlConnection db = new
MySqlConnection(connectionString)) {
                        db.Open();
                        string sql = "Select * From Mono;";

                        DataSet ds = new DataSet();

                        MySqlCommand cmd = new MySqlCommand(sql);
                        cmd.Connection = db;
                        MySqlDataAdapter da = new MySqlDataAdapter(cmd);

                        da.Fill(ds);

                        MySqlCommandBuilder builder = new
MySqlCommandBuilder(da);
                        DataRow row = ds.Tables[0].NewRow();
                        ds.Tables[0].Rows.Add(row);
                        row[0] = 99;
                        builder.DataAdapter.Update(new DataRow[] { row } );

                        Console.WriteLine("hello" + row[1]);
                        db.Close();
                }
        }

        static void Main() {
                try {
                        test1();
                } catch (Exception e) {
                        Console.WriteLine("test1 failed: " + e);
                }
                try {
                        test2();
                } catch (Exception e) {
                        Console.WriteLine("test2 failed: " + e);
                }
        }

}


-- 
Configure bugmail: https://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