English

How To: Save passwords from DBAccess connections in a project

Summary

This document contains a script that will check all database connections and save the passwords in the project. You can use it as the shutdown script in a project to ensure all passwords are saved automatically.

Procedure

  1. Open a new script window.

    A. Activate the Project window.
    B. Click the Scripts icon.
    C. Click New.

  2. Copy the following code into the script window.

    Code:
    theDocs = av.GetProject.GetDocs

    theViews = {}

    For Each aDoc in theDocs

    '-- Get the views associated with the project
    If (aDoc.GetClass.GetClassName = "View") then

    '-- Get the themes from each view
    theThemes = aDoc.GetThemes
    For Each t in theThemes

    '-- Get the SDE themes for the view
    If (t.GetClass.GetClassName = "DBTheme") then

    '-- Get each connection and save the password
    qD = t.GetQueryDef
    theCon = qD.GetConnection
    theCon.SavePassword(TRUE)
    End
    End
    End

    '-- Get the database tables associated with the project
    If (aDoc.GetClass.GetClassName = "DBTable") then

    '-- Get the connection and save the password
    tqD = aDoc.GetQueryDef
    tableCon = tqD.GetConnection
    tableCon.SavePassword(TRUE)
    End
    End

  3. Compile and run the script.

    Note:
    Follow the remaining steps if you want to make this the project shutdown script.

  4. Make the Project window active.
  5. Select Properties from the Project menu.
  6. Type the name of the script into the Shutdown text box and click OK. This script will run every time you exit the project.