INF: Changes to SQL-DMO Objects in SQL Server 7.0

ID: Q239794


The information in this article applies to:
  • Microsoft SQL Server version 7.0


SUMMARY

SQL Server Distributed Management Objects (DMO) has been redesigned and enhanced to reflect the new SQL Server 7.0 architecture and features, and there is a new DMO object model that must be used to administer SQL 7.0 servers. From the perspective of a SQL-DMO application, the most significant changes to the object model affect database creation and modification, backup and restore, and security.


MORE INFORMATION

The SQL Server 6.5 DMO object model was referred to as "SQLOLE". In SQL Server 7.0 you create a reference to "SQLDMO", instead. The two object models are very similar. If your DMO application must work with both SQL Server 6.5 and SQL 7.0, you may be able to use much of the same code, but there will probably be places where code branches are necessary to handle the differences between the different versions of the DMO objects. There is a sample application (DMOPing) provided with SQL Server 7.0 that demonstrates how to handle the initial connection to determine the SQL Server version so you can decide whether to create your SQLServer object from SQLOLE or SQLDMO. Refer to the SQL Server Books Online topic: "Dmoping (C++) (SQL-DMO)" for a description. Also, you can find the code on the SQL Server CD-ROM in the \DevTools\Samples\sqldmo\cpp\dmoping directory.

Below is sample Visual Basic code that demonstrates SQL Server version detection and instantiation of a SQLServer object from the appropriate library. Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Solution Provider or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Solution Providers, please see the following page on the World Wide Web:

http://www.microsoft.com/mcsp/
For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp

    Dim sServer As String
    Dim oSQLObj As Object
    
    'Define the server name to which you want to connect. 
    sServer = "MyServer"

    'Create the 7.0 version of SQLServer object.
    Set oSQLObj = CreateObject("SQLDMO.SQLServer") 
    version = oSQLObj.PingSQLServerVersion(sServer)
    If version <> SQLDMOSQLVer_70 Then
       'Create 6.x version if necessary.
       Set oSQLObj = nothing
       Set oSQLObj = CreateObject("SQLOLE.SQLServer") 
    End If
    
    'Make a connection through Microsoft Windows NT authentication.
    oSQLObj.LoginSecure = True
    oSQLObj.Connect(sServer) 
If you are using VBScript, you will need to define the appropriate constants to use this code:

    SQLDMOSQLVer_60 = 2
    SQLDMOSQLVer_65 = 4
    SQLDMOSQLVer_70 = 8
    SQLDMOSQLVer_Pre_60 = 1
    SQLDMOSQLVer_Unknown = 0 
The following objects and collections are new to the SQL Server 7.0 version of DMO:
FileGroups
FileGroup
DBFiles
DBFile
LogFiles
LogFile
ServerRoles
ServerRole
DatabaseRoles
DatabaseRole
Restore
RestoreSink
JobFilter
JobSchedules
JobSchedule
Schedule
LinkedServers
LinkedServer
LinkedServerLogins
LinkedServerLogin
Jobs
Job
TargetServers
TargetServer
TargetServerGroups
TargetServerGroup
JobCategories
AlertCategories
OperatorCategories
Category
JobSteps
JobStep
The following objects and collections have been renamed in the SQL Server 7.0 version of SQL-DMO:
Devices to BackupDevices
Device to BackupDevice
Executive to JobServer
HistoryFilter to JobHistoryFilter
These objects and collections are present in the SQL Server 6.5 DMO object model, but have been removed in the SQL Server 7.0 version:
Tasks
Task
The Group object is a special object that is accessible to 6.x servers only.

Additional query words: SQLDMO

Keywords : SSrvProg kbSQLServ700
Version : winnt:7.0
Platform : winnt
Issue type : kbinfo


Last Reviewed: October 26, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.