Well, DateTime.Now there is basically DateTime.Now.ToString()
which,for you, would be 07-18-2011 11:23 I suspect.
try it in this format:
2004-11-07 15:42:26
so ToString("yyyy-MM-dd HH:mm:ss")
or somethign that that
I dont think there is a country around - except maybe japan? - who
have dates that computers accept properly.
On Mon, Jul 18, 2011 at 20:42, Wally McClure
<[email protected]> wrote:
> 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
>
>
--
Nic Wise
t. +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise
b. http://www.fastchicken.co.nz/
mobileAgent (for FreeAgent): get your accounts in your pocket.
http://goo.gl/IuBU
Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa
London Bike App: Find the nearest Boris Bike, and get riding! http://goo.gl/Icp2
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch