Solved

Common Connection routine for VB forms

Posted on 1998-06-18
7
160 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
  • 4
  • 3
7 Comments
 

Author Comment

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

Accepted Solution

by:
marti earned 50 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now