Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Use a record set without keeping connection open?

Posted on 2002-05-22
5
Medium Priority
?
159 Views
Last Modified: 2010-05-02
First of all I'm new to VB and programming in general so I may not be explaining my problem correctly.
I've created a VB 6 app. that will be used to deliver quizzes to highschool students. The questions and answers are in an Access 2000 database table with each record being one question and it's multiplechoice answers eg.
QuestionNumber, Question, RightAnswer, WrongAnswr1....
Using ADO I create a recordset of the table and "Dowhile not rs.EOF" present the user with one question at a time. The problem is that the connection to the database must (or does it?) remain open throughout the quiz so the number of concurrent users is very limited without an SQL server.
How can I open the connection, create the recordset, close the connection and then cycle through the questions.

Is this clear?
0
Comment
Question by:sooketech
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
Bahnass earned 300 total points
ID: 7027691
just

set RecSet.connection =Nothing

U can Use Ur Disconnected Recordset for reading but No    UPDATE
I think this is fair for Ur app
0
 
LVL 1

Author Comment

by:sooketech
ID: 7027815
Could you give a little more info on exactly how I do that? Here's the Code I'm using to create the recordset.
---------------------------------------
'CHOOSE THE TABLE AND FIELDS WE'LL BE USING FOR THE QUIZ
    strSQL = "SELECT fldQuestion,fldCorrect,fldWrong1,fldWrong2,fldWrong3"
    strSQL = strSQL & "FROM tblQuiz"
    strSQL = strSQL & intQuizNumber
'CREATE THE RECORD SET
    OpenConnection 'FUNCTION (SEE BELOW)

    Set rsQuiz = New ADODB.Recordset
    With rsQuiz
        .ActiveConnection = cnQuizzer
        .CursorLocation = adUseClient
        .CursorType = adOpenForwardOnly
        .Source = strSQL
        .Open
    End With
'I NEED TO CLOSE THE CONNECTION BEFORE HERE
Do While Not rsQuiz.EOF
----------------------------------------

Public Sub OpenConnection()
    'establish the connection object
    Set cnQuizzer = New ADODB.Connection
    With cnQuizzer
        .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Quizzer.mdb;Persist Security Info=False"
        .Open
    End With
End Sub
0
 
LVL 20

Expert Comment

by:hes
ID: 7027833
As Bahnass said change your code from



   Set rsQuiz = New ADODB.Recordset
   With rsQuiz
       .ActiveConnection = cnQuizzer
       .CursorLocation = adUseClient
       .CursorType = adOpenForwardOnly
       .Source = strSQL
       .Open
   End With
'I NEED TO CLOSE THE CONNECTION BEFORE HERE
Do While Not rsQuiz.EOF

TO:



   Set rsQuiz = New ADODB.Recordset
   With rsQuiz
       .ActiveConnection = cnQuizzer
       .CursorLocation = adUseClient
       .CursorType = adOpenForwardOnly
       .Source = strSQL
       .Open
   End With
cnQuizzer.Close
Set cnQuizzer = Nothing
Do While Not rsQuiz.EOF
0
 
LVL 1

Author Comment

by:sooketech
ID: 7028107
Thanks Bahnass, after some playing around I got it to work. Thanks also to hes.
0
 
LVL 3

Expert Comment

by:Bahnass
ID: 7029056
Thanks Both

Sorry 4 not being here


Grade B Accepted
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question