SQLDMOÔÚVBÖеÄÓ¦ÓÃ
¡¡¡¡SQLDMO£¨SQL Distributed Management Objects£¬SQL·Ö²¼Ê½¹ÜÀí¶ÔÏ󣩷â×° Microsoft SQL Server 2000 Êý¾Ý¿âÖеĶÔÏó¡£SQL-DMO ÔÊÐíÓÃÖ§³Ö×Ô¶¯»¯»ò COM µÄÓïÑÔ±àдӦÓóÌÐò£¬ÒÔ¹ÜÀí SQL Server °²×°µÄËùÓв¿·Ö¡£ SQL-DMO ÊÇ SQL Server 2000 ÖÐµÄ SQL Server ÆóÒµ¹ÜÀíÆ÷ËùʹÓõÄÓ¦ÓóÌÐò½Ó¿Ú (API);Òò´ËʹÓà SQL-DMO µÄÓ¦ÓóÌÐò¿ÉÒÔÖ´ÐÐ SQL Server ÆóÒµ¹ÜÀíÆ÷Ö´ÐеÄËùÓй¦ÄÜ¡£
¡¡¡¡SQL-DMO ÓÃÓÚ±ØÐë°üº¬ SQL Server ¹ÜÀíµÄÈκÎ×Ô¶¯»¯»ò COM Ó¦ÓóÌÐò£¬ÀýÈ磺
¡¡¡¡1. ·â×° SQL Server ×÷Ϊ×Ô¼ºµÄÊý¾Ý´æ´¢²¢Ï뾡Á¿¼õÉÙÓû§µÄ SQL Server ¹ÜÀíÈÎÎñµÄÓ¦ÓóÌÐò¡£
¡¡¡¡2. ÔÚ³ÌÐò±¾Éí²¢ÈëÁËרÃŵĹÜÀíÂß¼µÄÓ¦ÓóÌÐò¡£
¡¡¡¡3. ÏëÔÚ×Ô¼ºµÄÓû§½çÃæÖм¯³É SQL Server ¹ÜÀíÈÎÎñµÄÓ¦ÓóÌÐò¡£
¡¡¡¡SQLDMO¶ÔÏóÀ´×ÔSQLDMO.dll£¬SQLDMO.dllÊÇËæSQL Server2000Ò»Æð·¢²¼µÄ¡£SQLDMO.dll×ÔÉíÊÇÒ»¸öCOM¶ÔÏó£¬Òò´Ë£¬ÔÚÄãµÄ.NETÏîÄ¿Àï±ØÐëÏÈÒýÓÃËü¡£
¡¡¡¡µÃµ½ÍøÂçÖеÄSQL·þÎñÆ÷µÄÁÐ±í£º
'µÃµ½SQL·þÎñÆ÷µÄÁбí
'±ØÐë°²×°SQL SERVER 2000 SP2 ¼°ÒÔÉÏ°æ±¾
Dim I As Short
Dim sqlApp As New SQLDMO.Application()
Dim ServerName As SQLDMO.NameList
ServerName = sqlApp.ListAvailableSQLServers
For i = 1 To ServerName.Count
cbServer.Items.Add(ServerName.Item(i))
Next
¡¡¡¡µÃµ½Ö¸¶¨SQL·þÎñÆ÷ËùÓÐÊý¾Ý¿âµÄÁÐ±í£º
'µÃµ½Ö¸¶¨SQL·þÎñÆ÷ËùÓÐÊý¾Ý¿âµÄÁбí
Dim sqlApp As New SQLDMO.Application()
Dim oServer As New SQLDMO.SQLServer()
oServer.Connect("(local)", "sa", "sa")
cboDatabase.Items.Clear()
Dim db As SQLDMO.Database
For Each db In oServer.Databases
Me.cboDatabase.Items.Add(db.Name)
Next
¡¡¡¡µÃµ½ËùÓÐµÄ±í¡¢ÊÓͼ¡¢´æ´¢¹ý³Ì£º
Dim I As Short
Dim oServer As New SQLDMO.SQLServer()
oServer.Connect("(local)", "sa", "sa")
Dim db As New SQLDMO.Database()
For I = 1 To oServer.Databases.Count
If oServer.Databases.Item(I, "dbo").Name = "Northwind" Then Exit For
Next
If I > oServer.Databases.Count Then Exit Sub
db = oServer.Databases.Item(I, "dbo")
ListBox1.Items.Clear()
'µÃµ½ËùÓеĴ洢¹ý³Ì
For I = 1 To db.StoredProcedures.Count
ListBox1.Items.Add(db.StoredProcedures.Item(I, "dbo").Name)
Next
'µÃµ½ËùÓеıí
For I = 1 To db.Tables.Count
ListBox1.Items.Add
Ïà¹ØÎĵµ£º
Êýѧº¯Êý£ºÖ÷ÒªÓÃÀ´Íê³ÉÊýÖµ¼ÆËã¡£
£¨1£©abs£¨X£©£º¾ø¶ÔÖµº¯Êý£¬¼ÆËãXµÄ¾ø¶ÔÖµ£¬XΪһ¸öÊýÖµ±í´ïʽ¡£
£¨2£©sgn£¨X£©£º·ûºÅº¯Êý¡£¸Ãº¯ÊýµÄ¹¦ÄÜÊÇÅжÏXµÄ·ûºÅ¡£µ±X>0ʱ£¬º¯ÊýֵΪ1£»X<0ʱ£¬º¯ÊýֵΪ-1£»X=0ʱ£¬º¯ÊýֵΪ0.
£¨3£©exp£¨x£©£ºÃÝÔËË㺯Êý¡£·µ»ØeµÄX´ÎÃݵÄÖµ£¬·µ»ØֵΪ˫¾«¶ÈÐÍÊýÖµ¡£
£¨4£©log£¨x£©£º× ......
Option Explicit
Private Const ERROR_CACHE_FIND_FAIL As Long = 0
Private Const ERROR_CACHE_FIND_SUCCESS As Long = 1
Private Const ERROR_FILE_NOT_FOUND As Long = 2
Private Const ERROR_ACCESS_DENIED As Long = 5
Private Const ERROR_INSUFFICIENT_BUFFER As Long = 122
Private Const MAX_PATH As Long ......
Ò»Ö±ÏëдÏÂÊý¾Ý¿â²Ù×÷·½ÃæµÄ£¬Ö»ÊÇûʲôʱ¼ä£¨ºÃÏñÊǽè¿Ú£¬Ó¦¸ÃÊÇÀÁ»òÕßûÐÄÇé°É£¬ºÇºÇ£©¡£×î½ü·¢ÏÖCSDNÉÏ
»¹ÊÇÿÌìÓÐÈËÒªÎÊÕâЩÄÚÈÝ£¬ÎÒÓеÄʱºò¾ÍÀÁµÄ»Ø´ð£¬ºÇºÇ£¬Ö÷Òª²»¶ÏµÄÈ¥ÕÒ´úÂë¸øËûÃÇÀÛ°¡¡£ËùÒÔ»¹ÊÇÌý¸ßÈ˵ģ¬À´
¸öÒ»ÀÍÓÀÒÝ£¬×Ô¼ºÖØÐÂÎÂÏ°Ï£¬Ò²ºÃ¸øÆäËûÈËһЩ°ïÖú¡£
Õâ¸öÊ ......
'ÔÚÒýÓÃÀïÌí¼ÓADODB
Public vscn As ADODB.Connection
Public SQLString As String
SQLString = "Provider=SQLOLEDB.1;Password=ÃÜÂë;Persist Security Info=True;User ID=ÓÃ" & _
"»§;Initial Catalog=Êý¾Ý¿âÃû;Data Source=·þÎñÆ÷Ãû"
  ......
'ÕâÀïÊÇÆô¶¯¹ý³Ì[ʼþ»¥³â¾Í²»Ð´ÁË]
Dim f as frmMain
Sub Main
Set f=New frmMain
f.Show
End Sub
'ÕâÀïÊÇÒ»¸öÏß³ÌÀà¡£¡£¡£Ëæ±ãдɶ¡£¡£¡£
ˈ̞:BT
'ÕâÀïÊÇÖ÷´°¿Ú
Dim cBT as BT
Sub form_Load
'Ææ¹ÖµÄÎÊÌâ¾ÍÔÚÕâÀï...
Set cBT=CreateObject("¹¤³ÌÃû.BT")
'ÔÚL ......