Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7852059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:19:45+00:00 2026-06-02T19:19:45+00:00

I tried to insert data into the database, but when I select what I’ve

  • 0

I tried to insert data into the database, but when I select what I’ve insert, I get inconsistent data.

like, I insert a=”data1″, b=”data2″, c=”data3″

but when I select I get a=”0″, b=”data2″, c=”data3″

why I use the same method but some of them get different value..

Reference for my implement: SQLiteClient for WP (I tested his codes it run correctly, and I follow exactly how he done it, but then I get different outcomes..)

INSERT function:

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);

SELECT function:

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;
}

Also my UPDATE function:

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 q_title=@q_title,q_ques_a=@q_ques_a,q_ques_b=@q_ques_b,q_ques_c=@q_ques_c,q_ques_d=@q_ques_d,q_ans=@q_ans WHERE q_id=@q_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);

Appreciate anyone who can help me out!!!

*Or if you think I should give up SQLite and go for other database, please let me know, I pick SQLite at first place because it handle simple query like mysql, and the FF SQLite Manager..

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T19:19:47+00:00Added an answer on June 2, 2026 at 7:19 pm

    Ok, I’ve tested around and finally found that, I need to INSERT or UPDATE ALL COLUMNS together at once then only I can get the job done correctly, I’m not sure this happens because of the DBHelper restriction or from SQLiteClient.

    Further details:

    for example, if my preset database declared 4 columns as below:

    [q_id, q_title, q_ques, q_ans] (q_id as Auto Increment)
    

    then when I doing INSERT or UPDATE, even I just need to insert the q_title ONLY (while leave the q_ques and q_ans with DEFAULT values), I will need to include all columns’ parameters in the operation:

    INSERT INTO tlg_question (q_title,q_ques,q_ans) VALUES (@q_title,@q_ques,@q_ans)";
    

    Not like what I usually doing in PHP MYSQL, I can simply INSERT/UPDATE the particular column I like without problem:

    INSERT INTO tlg_question (q_title) VALUES (@q_title)";
    

    p/s: I’m new in SQLite and C#, please advise/correct me if you know whats actually happening..

    Thanks! 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to insert some data into my database (sql server/local file) but it
I'm attempting to use AJAX to insert data into a database, but am unable
I'm trying to insert a data into oracle database(version 11g xe).But when i'm trying
I'm trying to insert into a database with the code below, I've tried everything
Scenario: I load some data into a local MySQL database each day, about 2
i'm trying to insert multiple data using a query, i've tried the implode function,
I have an Sqlite database in which I want to select rows of which
I'm trying to use the OleDb CSV parser to load some data from a
I'm running the following SQL inside a cfquery tag INSERT INTO Meeting_RFPMeetings (RFP_ID, Meeting_ID,
I'm importing data from a CSV file that comes from excel, but i can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.