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

x
?
Solved

Common Connection routine for VB forms

Posted on 1998-06-18
7
Medium Priority
?
166 Views
Last Modified: 2011-09-20
My application is VB5.0/MSSQLServer based and consists of many forms. I want user to enter his/her login and password one time and then after I would like all the forms, which user navigates thru, should be connected with the supplied login and password (user is not asked to give login and password again).

Can anyone suggest a common subroutine method to do it.
0
Comment
Question by:rolee
[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
  • 4
  • 3
7 Comments
 

Author Comment

by:rolee
ID: 1463688
Edited text of question
0
 
LVL 2

Accepted Solution

by:
marti earned 200 total points
ID: 1463689
You have to have only one global rdoConnection object.
0
 
LVL 2

Expert Comment

by:marti
ID: 1463690
Set the connection only once and use only that connection object to Qry the database. If you need some code please send a comment.
0
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.

 

Author Comment

by:rolee
ID: 1463691
Just to add:we are using DAO (not RDO).
I would be glad if you could provide some sample code.
Thanks
0
 
LVL 2

Expert Comment

by:marti
ID: 1463692
For DAO it should be the same. Just use one global variable of type Database. Set it when the application starts and use it all over the project.
Regards
0
 

Author Comment

by:rolee
ID: 1463693
Can you give an example. I am sorry as I might be asking too much. Please help.
0
 
LVL 2

Expert Comment

by:marti
ID: 1463694
If SQLServer tables are attached to an existing Access DB you have to use the first example.
Otherwise you may use the next two.

This example uses the OpenDatabase method to open one Microsoft Jet database and two Microsoft Jet-connected ODBC databases.

Sub OpenDatabaseX()

      Dim wrkJet As Workspace
      Dim dbsNorthwind As Database
      Dim dbsPubs As Database
      Dim dbsPubs2 As Database
      Dim dbsLoop As Database
      Dim prpLoop As Property

      ' Create Microsoft Jet Workspace object.
      Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)

      ' Open Database object from saved Microsoft Jet database
      ' for exclusive use.
      MsgBox "Opening Northwind..."
      Set dbsNorthwind = wrkJet.OpenDatabase("Northwind.mdb", _

True)

      ' Open read-only Database object based on information in
      ' the connect string.
      MsgBox "Opening pubs..."
      Set dbsPubs = wrkJet.OpenDatabase("Publishers", _
            dbDriverNoPrompt, True, _
            "ODBC;DATABASE=pubs;UID=sa;PWD=;DSN=Publishers")

      ' Open read-only Database object by entering only the
      ' missing information in the ODBC Driver Manager dialog
      ' box.
      MsgBox "Opening second copy of pubs..."
      Set dbsPubs2 = wrkJet.OpenDatabase("Publishers", _

dbDriverCompleteRequired, True, _
            "ODBC;DATABASE=pubs;DSN=Publishers;")

      ' Enumerate the Databases collection.
      For Each dbsLoop In wrkJet.Databases
            Debug.Print "Database properties for " & _
                  dbsLoop.Name & ":"

            On Error Resume Next
            ' Enumerate the Properties collection of each Database
            ' object.
            For Each prpLoop In dbsLoop.Properties
                  If prpLoop.Name = "Connection" Then
                        ' Property actually returns a Connection object.

Debug.Print "    Connection[.Name] = " & _
                              dbsLoop.Connection.Name
                  Else
                        Debug.Print "    " & prpLoop.Name & " = " & _
                              prpLoop
                  End If
            Next prpLoop
            On Error GoTo 0

      Next dbsLoop

      dbsNorthwind.Close
      dbsPubs.Close
      dbsPubs2.Close
      wrkJet.Close

End Sub
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

610 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