我試圖將數據插入數據庫,但是當我選擇插入的內容時,我得到的數據不一致。Windows Phone中的SQLite客戶端不一致的錯誤
等,我插入= 「DATA1」,B = 「DATA2」,C = 「DATA3」
但是當我選擇我獲得= 「0」,B = 「DATA2」,C =」數據3"
爲什麼我用同樣的方法,但其中一些得到不同的價值..
參考我實現:SQLiteClient for WP(我測試了它的代碼運行正確,於是我跟着他究竟是怎麼做到的,但然後我得到不同的結果..)
INSERT功能:
String t_title = txtTitle.Text;
String t_img = "test";
String t_answer_a = txtAnswer1.Text;
String t_answer_b = txtAnswer2.Text;
String t_answer_c = txtAnswer3.Text;
String t_answer_d = txtAnswer4.Text;
String t_answer = txtAnswer1.Text;
int t_cat = 1;
int rec;
Random rnd = new Random();
string strInsert = " INSERT INTO tlg_question (q_title,q_img,q_ques_a,q_ques_b,q_ques_c,q_ques_d,q_ans,q_cat) VALUES (@q_title,@q_img,@q_ques_a,@q_ques_b,@q_ques_c,@q_ques_d,@q_ans,@q_cat)";
tlg_question tst = new tlg_question
{
q_title = t_title,
q_img = t_img,
q_ques_a = t_answer_a,
q_ques_b = t_answer_b,
q_ques_c = t_answer_c,
q_ques_d = t_answer_d,
q_ans = t_answer,
q_cat = t_cat
};
rec = (Application.Current as App).db.Insert<tlg_question>(tst, strInsert);
選擇功能:
ObservableCollection<tlg_question> _tlg_questionEntries = null;
string strSelect = "SELECT q_id,q_title,q_img,q_ques_a,q_ques_b,q_ques_c,q_ques_d,q_ans,q_cat FROM tlg_question ORDER BY q_id DESC LIMIT 0,1";
_tlg_questionEntries = (Application.Current as App).db.SelectObservableCollection<tlg_question>(strSelect);
foreach (tlg_question data in _tlg_questionEntries)
{
qid = data.q_id;
txtTitle.Text += data.q_title;
img = data.q_img;
txtAnswer1.Text += data.q_ques_a;
txtAnswer2.Text += data.q_ques_b;
txtAnswer3.Text += data.q_ques_c;
txtAnswer4.Text += data.q_ques_d;
}
而且我的更新功能:
String t_title = txtTitle.Text;
String t_answer_a = txtAnswer1.Text;
String t_answer_b = txtAnswer2.Text;
String t_answer_c = txtAnswer3.Text;
String t_answer_d = txtAnswer4.Text;
int rec;
Random rnd = new Random();
string strUpdate = " UPDATE tlg_question SET [email protected]_title,[email protected]_ques_a,[email protected]_ques_b,[email protected]_ques_c,[email protected]_ques_d,[email protected]_ans WHERE [email protected]_id";
tlg_question tst = new tlg_question
{
q_id = qid,
q_title = t_title,
q_ques_a = t_answer_a,
q_ques_b = t_answer_b,
q_ques_c = t_answer_c,
q_ques_d = t_answer_d,
q_ans = t_answer_a
};
rec = (Application.Current as App).db.Update<tlg_question>(tst, strUpdate);
欣賞人誰可以幫我!
*或者,如果你認爲我應該放棄SQLite和去其他數據庫,請讓我知道,我在挑首位SQLite的,因爲它處理,如MySQL簡單的查詢,以及FF SQLite的經理..
謝謝!