I have the code below:                  string dir = 
Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);           
           string dbFile = "Test.db3";                     string db = 
Path.Combine(dir, dbFile);                  string dbConn = String.Format("Data 
Source={0}", db);                   SqliteConnection conn = new 
SqliteConnection();                 SqliteCommand cmd = new SqliteCommand();    
                    if ( !File.Exists(db) )                 {                   
            SqliteConnection.CreateFile(db);                                }   
                    conn.ConnectionString = dbConn;                 
cmd.Connection = conn;                  conn.Open();                    
string[] sql = new string[]{ "CREATE TABLE IF NOT EXISTS TESTTABLE(TID INTEGER 
PRIMARY KEY, DT DATETIME, DEGREES INTEGER )",                            
String.Format("INSERT INTO TESTTABLE (DT, DEGREES) VALUES ('{0}', 87.8)", 
DateTime.Now) };                      foreach(string s in sql)                  
      {                               cmd.CommandText = s;                      
      cmd.ExecuteNonQuery();                  }                       
SqliteCommand sqlCm = new SqliteCommand(conn);                  string sSql = 
"select DT, DEGREES from TESTTABLE";                      sqlCm.CommandText = 
sSql;                       sqlCm.CommandType = CommandType.Text;               
    SqliteDataAdapter sda = new SqliteDataAdapter(sqlCm);                   
DataSet ds = new DataSet();                     sda.Fill(ds, "TESTTABLE");      
                lblOutput.Text = String.Format("Records returned: {0}", 
ds.Tables["TESTTABLE"].Rows.Count);                     if ( conn.State != 
ConnectionState.Closed )                     {                               
conn.Close();                           }                       
sqlCm.Dispose();                        sda.Dispose();                  
conn.Dispose();
When I run the code as is, I get an exception in the simulator.  The exception 
is "invalid input string."  The exception comes from the DateTime column in my 
query.  When I take the datetime column out of my query, the exception goes 
away.  This is either a bug in the datatime parsing in mt or a bug in how I am 
inserting data into my table.  Any ideas/thoughts are appreciated.
Wally                                     
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to