Application.DeleteFromDatabase Method

Project Developer Reference

Deletes a project stored in a database.

Syntax

expression.DeleteFromDatabase(Name, UserID, DatabasePassWord, FormatID)

expression   A variable that represents an Application object.

Parameters

Name Required/Optional Data Type Description
Name Optional String The name of the source file or data source to open, and the name of the project to delete from the database.
UserID Optional String A user ID to use when accessing the database.
DatabasePassWord Optional String A password to use when accessing the database.
FormatID Optional String The file or database format. If Project recognizes the format of the file specified with Name, FormatID is ignored. Can be one of the following format strings:
Format StringDescription
"MSProject.mpd"Project database
"MSProject.odbc"ODBC database
"MSProject.mdb"Microsoft Access database
Format String Description
"MSProject.mpd" Project database
"MSProject.odbc" ODBC database
"MSProject.mdb" Microsoft Access database

Return Value
Boolean

Remarks

The Name argument must contain a file name string, or an ODBC data source name (DSN), and the project name string. The syntax for a data source is <DataSourceName>\Projectname. The less than (<) and greater than (>) symbols must be included, and a backslash ( \ ) must separate the data source name from the project name. The DataSourceName itself can either be one of the ODBC data source names installed on the computer, a file DSN, or a path and file name for a file-based database.

In the following examples, [My Documents] is the full path of your My Documents folder, and [Program Files] is the full path of your Program Files folder:

"<Corporate SQL Database>\Factory Construction"

"<*[My Documents]\*PROJECT1.MDB>\System Roll-out Plan"

"<[Program Files]\Common Files\ODBC\Data Sources\Projects Database.dsn>\Project X"

Example
The following example deletes projects from a Project database, as specified by the user.

Visual Basic for Applications
  Sub KillProjects()
    Dim PathAndDB As String, ProjectName As String
    Dim Continue As Long    ' Used to store user response
Continue = vbYes    ' Set to Yes so that loop runs

PathAndDB = InputBox$("Enter the path and file name of the Project" &amp; _
    " database to open, including extension: ")

Do Until Continue = vbNo
    ProjectName = InputBox$("Enter the name of the project to delete: ")
    <strong class="bterm">DeleteFromDatabase</strong> "&lt;" &amp; PathAndDB &amp; "&gt;\" &amp; ProjectName, _
        FormatID:="MSProject.mpd"
    Continue = MsgBox("Project " &amp; ProjectName &amp; " deleted from database." &amp; _
        vbCrLf &amp; vbCrLf &amp; "Delete another?", vbYesNo)
Loop

End Sub

See Also