?
Solved

Common Connection routine for VB forms

Posted on 1998-06-18
7
Medium Priority
?
165 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month13 days, 2 hours left to enroll

777 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