[Mono-bugs] [Bug 677096] New: Support DataTable + Mono.Data.Sqlite

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Mar 4 13:21:57 EST 2011


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

https://bugzilla.novell.com/show_bug.cgi?id=677096#c0


           Summary: Support DataTable + Mono.Data.Sqlite
    Classification: Mono
           Product: MonoDroid
           Version: SVN
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Enhancement
          Priority: P5 - None
         Component: Class Libraries
        AssignedTo: jpryor at novell.com
        ReportedBy: jpryor at novell.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


Problem: Android 2.2 includes enough in libsqlite.so to make many uses of
Mono.Data.Sqlite work, but things break when trying to use Mono.Data.Sqlite +
System.Data.DataTable, because the sqlite3_column_origin_name() function is
missing.

See also:

http://lists.ximian.com/mailman/private/monodroid/2011-February/003302.html

It might be useful to fix the DataTable Load & Fill methods so that
sqlite3_column_origin_name() is avoided; the above email suggests:


  SqliteDataReader reader = mycommand.ExecuteReader();

  // Add all the columns.
  for (int i = 0; i < reader.FieldCount; i++)
  {
    DataColumn col = new DataColumn();
    col.DataType = reader.GetFieldType(i);
    col.ColumnName = reader.GetName(i);
    dt.Columns.Add(col);
  }

  while (reader.Read())
  {
    DataRow row = dt.NewRow();
    for (int i = 0; i < reader.FieldCount; i++)
    {
      // Ignore Null fields.
      if (reader.IsDBNull(i)) continue;

      if (reader.GetFieldType(i) == typeof(String))
      {
        row[dt.Columns[i].ColumnName] = reader.GetString(i);
      }
      else if (reader.GetFieldType(i) == typeof(Int16))
      {
        row[dt.Columns[i].ColumnName] = reader.GetInt16(i);
      }
      else if (reader.GetFieldType(i) == typeof(Int32))
      {
        row[dt.Columns[i].ColumnName] = reader.GetInt32(i);
      }
      else if (reader.GetFieldType(i) == typeof(Int64))
      {
        row[dt.Columns[i].ColumnName] = reader.GetInt64(i);
      }
      else if (reader.GetFieldType(i) == typeof(Boolean))
      {
        row[dt.Columns[i].ColumnName] = reader.GetBoolean(i); ;
      }
      else if (reader.GetFieldType(i) == typeof(Byte))
      {
        row[dt.Columns[i].ColumnName] = reader.GetByte(i);
      }
      else if (reader.GetFieldType(i) == typeof(Char))
      {
        row[dt.Columns[i].ColumnName] = reader.GetChar(i);
      }
      else if (reader.GetFieldType(i) == typeof(DateTime))
      {
        row[dt.Columns[i].ColumnName] = reader.GetDateTime(i);
      }
      else if (reader.GetFieldType(i) == typeof(Decimal))
      {
        row[dt.Columns[i].ColumnName] = reader.GetDecimal(i);
      }
      else if (reader.GetFieldType(i) == typeof(Double))
      {
        row[dt.Columns[i].ColumnName] = reader.GetDouble(i);
      }
      else if (reader.GetFieldType(i) == typeof(float))
      {
        row[dt.Columns[i].ColumnName] = reader.GetFloat(i);
      }
      else if (reader.GetFieldType(i) == typeof(Guid))
      {
        row[dt.Columns[i].ColumnName] = reader.GetGuid(i);
      }
    }

    dt.Rows.Add(row);
  }

  reader.Close();

-- 
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