Question:

Access 2007 in VB 2005, running a query?

by  |  earlier

0 LIKES UnLike

Ok, what i plan to do is to make a Who Wants To Be A Millionaire game. the questions are loaded into a database, along with there ID number, possible answers and correct answer. What i want to do is use Visual Basic 2005 to create the program. The Database is already loaded into VB. the two files in resources are DBMoney.mdb and DBMoneyDataSet.xsd i want to run a query inside VB that will bring up the question in a label, and the 4 possible questions in 4 separate buttons. When one of the box's is clicked, the text in the button is checked with the correct answer. Is this even possible? and if so, any hints on how i can go about achieving this?

Thanks, Chris =)

 Tags:

   Report

1 ANSWERS


  1. Its not very hard since you have set-up your database and the programming language to use. Heres a hint, hope this helps.

    First you must create a connection between MS Access 2007 and your VB program, your ODBC Connection or OLEDB Connection.(try a search on google and you'll find many helpful topics on these)

    Then, once successfully connection to your database, execute a query from it and put it a DATATABLE, here a sample

    Dim adapter as New OLEDBAdapter("Select * from questions", myOLEDBConnection)

    Dim tempTB as New DataTable

    adapter.Fill(tempTB)

    return tempTB

    Then, you have a recordset of your questions with answers on your application. To display it in a Label, you can loop through each record and assign its value to the Label.Text property

    Dim dRow as DataRow

    foreach dRow in tempTB.Rows



        Label1.Text = dRow("Question").ToString()

        Button1.Text = dRow("AnswerA").ToString()

    end foreach

    hope this helps

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.