Sqldmo. dll is released along with SQL Server2000. Sqldmo. dll itself is a COM Object
Sqldmo (SQL distributed management objects, SQL distributed management object) encapsulates objects in the Microsoft SQL Server 2000 database. SQL-DMO allows applications to be written in languages Supporting automation or comProgramTo manage all parts installed on SQL Server. SQL-DMO is the application interface (API) used by SQL Server Enterprise Manager in SQL Server 2000; therefore, applications that use SQL-DMO can execute all the functionality that SQL Server Enterprise Manager performs.
------
General Relationship Between sqlserver:
Application --> sqlserver --> Database
------
The instance sqldmo mainly uses the following classes:
Sqldmo. Application (created using sqldmo. applicationclass ),
Sqldmo. sqlserver (created using sqldmo. sqlserverclass and used its connect to the database server ),
Sqldmo. namelist (you can use it and application to obtain the server set. For other information, see its API)
Sqldmo. Database (you can use it to obtain a database set with sqlserver. databases)
Example 1: Obtain the SQL Server list in the LAN
The listavaiablesqlservers of the application is used to obtain the namelist, 1 Sqldmo. Application sqlapp = New Sqldmo. applicationclass ();
2 Sqldmo. namelist names = Sqlapp. listavailablesqlservers ();
3 Serverlist. Items. Clear ();
4 For ( Int I = 1 ; I < Names. Count; I ++ )
5 {
6If(Names. Item (I)! =Null)
7Serverlist. Items. Add (names. Item (I ));
8}
9 If (Serverlist. Items. Count > 0 )
10 {
11Serverlist. selectedindex= 1;
12}
13 Else
14 {
15Serverlist. Text= "No available SQL Server";
16}
Example 2: Obtain the Database List under a server:
It mainly uses sqlserver and its attribute databases 1
2 Sqldmo. sqlserver Database = New Sqlserverclass ();
3 Try
4 {
5 Database. Connect (serverlist. selecteditem. Text, " SA " , "" );
6 Databaselist. Items. Clear ();
7 Foreach (Sqldmo. Database DB In Database. databases)
8 {
9Databaselist. Items. Add (db. Name );
10}
11 }
12 Catch (System. Exception ee)
13 {
14Databaselist. Items. Clear ();
15Databaselist. Items. Add ("Unable to connect to the selected Server");
16}
Then, you can get the database attributes...
Pai_^