[Mono-list] Bug (?) in SqliteDataReader

Nikki Locke nikki at trumphurst.com
Fri May 19 10:00:26 EDT 2006


Nikki Locke wrote:
> Joshua Tauberer wrote: 
> > I don't think there should be a database that can't be read using any 
> > method, even if it wasn't created with Mono.Data.SqliteClient and even 
> > if it has crazy nonuniform data in columns. 
>  
> Well, it is currently possible (actually, easy) to write a data row using the 
> existing Mono.Data.SqliteClient library which cannot be read back! 

> Conclusion: 
> The existing code does not satisfy your requirement. It does allow you to store 
> and retrieve floating point numbers in DateTime fields, but not arbitrary 
> strings. I don't see that is significantly better than only allowing parseable 
> DateTimes in DateTime fields. 

I have been studying the code further.

In GetSchemaTable, you claim all the fields are strings.

However, in ReadpVm you go to some trouble to return the fields as other types.

This strikes me as inconsistent!

Having looked at the source, I see that the justification for treating integer 
values in DateTime columns as FileTimes is that is how they are treated in 
parameters. So I tried some code to insert a DateTime in a parameter. I used the 
following code...

    string sql = "insert into tester (testdate) values (?)";
#if MONO
    using (IDbCommand ac = new SqliteCommand(sql, _connection)) {
#else
    using (IDbCommand ac = new SQLiteCommand(sql, _connection)) {
#endif
      IDbDataParameter param = ac.CreateParameter();
      param.DbType = DbType.DateTime;
      param.Value = DateTime.Parse("2006-05-11 11:45:00");
      ac.Parameters.Add(param);
      ac.ExecuteNonQuery();
    }

This adds a record OK, but the value seems to be blank! If I run this code in 
Mono, and then in .NET with Finisar, the .NET version shows the record as 
containing "2006-05-11 11:45:00", but the Mono version shows nothing. I have tried 
"select * from tester" in sqlite3, and that also shows blank for the Mono-created 
database.

Do you have the Mono debugger working at all? Any hints how I can get it working?

-- 
Nikki Locke, Trumphurst Ltd.      PC & Unix consultancy & programming
http://www.trumphurst.com/




More information about the Mono-list mailing list