#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    4
    Rep Power
    0

    Thumbs down how to retrieve Questions table from my database


    i have created 2 tables with the name of Questions and Answers
    Questions Fields
    Q-No
    Question
    Answer1
    answer2
    answer3
    Answer4
    and Answers Dields
    Q_no
    Correct_answer
    -------------------
    now my question is how to retrieve Questions table from my database plz tell me the Query
    i want to dispay Q-no and Question in textbox and answers in radion boxes please how to?? can u tell me the query
    thanks dear

    thanks
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,118
    Rep Power
    4274
    Originally Posted by qureshi763
    now my question is how to retrieve Questions table from my database plz tell me the Query
    thanks
    SELECT * FROM questions

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    4
    Rep Power
    0

    Exclamation


    i have created 2 tables with the name of Questions and Answers
    Questions Fields
    Q-No
    Question
    Answer1
    answer2
    answer3
    Answer4
    ----------------------------
    Dear i want to dispay Q-no and Question in textbox and answers in radion boxes please how to?? can u tell me the query
    thanks dear
  6. #4
  7. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,118
    Rep Power
    4274
    Originally Posted by qureshi763
    Dear i want to dispay Q-no and Question in textbox and answers in radion boxes please how to?? can u tell me the query
    thanks dear
    which application language are you using? php?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    4
    Rep Power
    0

    Thumbs down


    dear i am using asp.net and in visual studion 2008
    thanks
  10. #6
  11. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,118
    Rep Power
    4274
    Originally Posted by qureshi763
    dear i am using asp.net and in visual studion 2008
    thanks
    okay, i've moved your thread to the .net forum

    may i give you some friendly advice? stop calling people "dear" -- that's not appropriate
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    4
    Rep Power
    0
    ok
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2011
    Posts
    122
    Rep Power
    0

    Query for get data from table:


    Hi
    Please find the answer.

    Query for get data from table:
    Select q.Q-No, q.Question, q.Answers1, q.Answers2, q.Answers3, q.Answers4, a.correctanswer from Questions q inner join Answers a on q.Q-no=a.Q-no

    There can be two approaches further using dataset or datatable and class object or class type list (Incase we need to fetch multiple questions)

    Result set of the query can be saved in class object which contains all the above fields as properties by using datareader.
    Letís assume we are using class Quize which contains below properties
    Q-No
    Question
    Answers1
    Answers2
    Answers3
    Answers4
    correctanswer

    At front end :
    Lets assume obj is Quize class type object containing the values fetch from the database

    Qnotxt.text= obj.Q-No.ToString();
    Qtext.text= obj. Question.ToString();
    Rdb1.text = obj. Answers1.ToString();
    Rdb1.text = obj. Answers2.ToString();
    Rdb1.text = obj. Answers3.ToString();
    Rdb1.text = obj. Answers4.ToString();

    *For multiple questions we could have used list of Quize type List<Quize>

    Thanks
    Diya

IMN logo majestic logo threadwatch logo seochat tools logo