[Mono-bugs] [Bug 380252] Mono.Data.SQLite crashes on call to SqliteDataAdapter.Fill(DataTable table) with simple SELECT
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Tue Jan 3 17:51:22 EST 2012
https://bugzilla.novell.com/show_bug.cgi?id=380252
https://bugzilla.novell.com/show_bug.cgi?id=380252#c6
Michael Carroll <mp3killa at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |NEEDINFO
CC| |mp3killa at gmail.com
InfoProvider| |moliveira at geostats.com
--- Comment #6 from Michael Carroll <mp3killa at gmail.com> 2012-01-03 22:51:20 UTC ---
Found workaround @
(http://lists.ximian.com/pipermail/mono-bugs/2011-March/109820.html)
BUT like the guy says on that Page.
----------------------------------
It might be useful to fix the DataTable Load & Fill methods so that
sqlite3_column_origin_name() is avoided; the above email suggests:
----------------------------------
I see this issue was opened AGES AGO!!! My word guys lets fix/improve this
shall we? Save the developers of the world lots of heartache...
-------------------------------------------------------------------------
Suggested workaround below worked okay for me, but oh so terribly ugly...
-------------------------------------------------------------------------
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