发信人: johnnyxu() 
整理人: chedong(1999-07-04 09:25:21), 站内信件
 | 
 
 
VB Tips(3) - 在VB中调用SQL Enterprise Manager的功能
 
 SQL Server 7.0服务器名: server1
 数据库名:database1
 表名: table1
 假如要查看表table1的properties,即在Enterprise Manager中
 运行table1的快捷菜单中的properties命令的结果:
 
 Dim oSQLNS As SQLNamespace
 Dim eSQLNSRootType As Long
 Dim strAppName As String
 Dim hRootItem As Long
 Dim hDatabases As Long
 Dim hDatabase As Long
 Dim hTables As Long
 Dim hTable As Long
 Dim objSQLNSObj As SQLNS.SQLNamespaceObject
     
 Set oSQLNS = New SQLNamespace
 eSQLNSRootType = SQLNSRootType_Server
 strAppName = "SQLNS Application;"
 oSQLNS.Initialize strAppName, eSQLNSRootType, _ 
   "Server=server1;UID=sa;pwd=;", hWnd
 If oSQLNS Is Nothing Then
    MsgBox "SQLNamespace could not be initiated. Terminating.", _ 
      vbOKOnly, "Error"
 End If
 hRootItem = oSQLNS.GetRootItem
 hDatabases = oSQLNS.GetFirstChildItem(hRootItem,_ 
   SQLNSOBJECTTYPE_DATABASES)
 hDatabase = oSQLNS.GetFirstChildItem(hDatabases, _ 
   SQLNSOBJECTTYPE_DATABASE, "database1")
 hTables = oSQLNS.GetFirstChildItem(hDatabase, _ 
   SQLNSOBJECTTYPE_DATABASE_TABLES)
 hTable = oSQLNS.GetFirstChildItem(hTables, _ 
   SQLNSOBJECTTYPE_DATABASE_TABLE, "table1")
 Set objSQLNSObj = oSQLNS.GetSQLNamespaceObject(hTable)
 objSQLNSObj.ExecuteCommandByID SQLNS_CmdID_PROPERTIES, _ 
   hWnd, SQLNamespace_PreferModal
 
 在VB中参照SQLNamespace Object Library,可以在客户端运行
 SQL Enterprise Manager中的界面。
  -- ※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 202.109.33.145]
  | 
 
 
 |