我有下面的代碼塊SQLite的不插入
SQLiteConnection cnn = new SQLiteConnection("Data Source=" + getDBPath());
cnn.Open();
SQLiteCommand mycommand = new SQLiteCommand(cnn);
string values = "'" + this.section + "','" + this.exception + "','" + this.dateTimeString + "'";
string sql = @"INSERT INTO Emails_Pending (Section,Message,Date_Time) values (" + values + ")";
mycommand.CommandText = sql;
mycommand.ExecuteNonQuery();
cnn.Close();
當我執行它,什麼都不會發生,沒有錯誤的產生,但沒有被插入,我究竟做錯了什麼?
DB的路徑是正確的! Insert語句作品,試圖在一個SQLLite GUI(沒有問題存在)
下面是SQL代碼段:
"INSERT INTO Emails_Pending (Section,Message,Date_Time) values ('Downloading Received Messages','Object reference not set to an instance of an object.','04.12.2009 11:09:49');"
對象引用未設置爲對象的實例,我猜是因爲我沒有使用事務。 – 2009-12-04 10:04:21