borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (*urgent! help needed here!)Next Topic (Storing of infos and scrolling in label *urgent!) New Topic New Poll Post Reply
AndreaVB Forum : VB.Net : quiz creation!!! PLease HelP!
Poster Message
sunny9
Level: Graduate

Registered: 12-12-2006
Posts: 10

icon quiz creation!!! PLease HelP!

hey, can anyone help? this piece of code shows the first question in my recordset and then goes to another question in the recordset and thats it! theres no third, fourth, fifth question etc etc only two questions seem to load up (i can go back and forth from only these 2 questions).
below is the code im using. the code dosent seem to work correctly.
plz help


Dim strsql As String
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim databasename As String  


cnn = New ADODB.Connection
        databasename = "C:path etc etc"
        cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
            & dbname & ";Persist Security Info=False"
        cnn.Open()
        strsql = "SELECT quizquestion, [optionanswer 1], [optionanswer 2], [optionanswer 3] FROM table"

        rs = New ADODB.Recordset
        rs.Open(strsql, cnn)

TextBox1.Text = myRecordSet.Fields("quizquestion").Value
TextBox2.Text = myRecordSet.Fields("optionanswer 1").Value
TextBox3.Text = myRecordSet.Fields("optionanswer 2").Value
        
        rs.MoveNext()
end sub



using vb.net 2005 and access as database.

09-01-2007 at 10:44 AM
View Profile Send Email to User Show All Posts | Quote Reply
stickleprojects
Level: Moderator


Registered: 09-09-2002
Posts: 891
icon Re: quiz creation!!! PLease HelP!

Hi
It appears that you are calling the "Open" whenever you click a button.
You should call the open only once whilst the form is alive.

Example:

In the form class declaration:
private m_objRS as adodb.recordset

in the form_load

Dim strsql As String
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim databasename As String  


cnn = New ADODB.Connection
        databasename = "C:path etc etc"
        cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
            & dbname & ";Persist Security Info=False"
        cnn.Open()
        strsql = "SELECT quizquestion, [optionanswer 1], [optionanswer 2], [optionanswer 3] FROM table"

        rs = New ADODB.Recordset
        rs.Open(strsql, cnn)

       m_objRS = rs

In the button_click for next (ie. cmdNext_Click)
m_objRS.MoveNext


Hope that is clearer.
Regards,
Kieron



____________________________
Build it better, faster, quicker, easier.. then fix it (non-offical MS mission statement)

14-01-2007 at 06:45 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB.Net : quiz creation!!! PLease HelP!
Previous Topic (*urgent! help needed here!)Next Topic (Storing of infos and scrolling in label *urgent!) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder