X hits on this document

PDF document

The “SQL Server Management Objects” series - page 3 / 6





3 / 6


The “SQL Server Management Objects” series

As the program is executed, it immediately tries to connect the SQL Server using Windows authentication. This is done by setting the LoginSecure to True, followed by calling the Connect method. Another alternative to connect is through the SQL Server authentication. If you wish to have more explanations on various methods to connect the SQL Server, please read the first article as suggested earlier.

The next lines are used to retrieve the database list from the SQL Server instance and put it in a combo box. Finally the last lines prepare the header of the list view control for the table list.

The table list is refreshed each time the database selection in the combo box is changed, the “All” check box is cleared or marked, or the object type radio buttons are changed. The piece of code that refreshes the object list is show in the following script.

... private void RefreshObjectList() { ...

//enumerate user stored procedures if (spList) { foreach (Microsoft.SqlServer.Management.Smo.StoredProcedure sp in database.StoredProcedures) { if (!sp.IsSystemObject) //show only user objects { L i s t V i e w I t e m i t e m = t h i s . l v O b j e c t . I t e m s . A d d ( s p . S c h e m a + " . + sp.Name); item.SubItems.Add("Stored Procedure"); "




//enumerate user functions if (funcList) { foreach (Microsoft.SqlServer.Management.Smo.UserDefinedFunction fn in database.UserDefinedFunctions) { if (!fn.IsSystemObject) //show only user objects { L i s t V i e w I t e m i t e m = t h i s . l v O b j e c t . I t e m s . A d d ( f n . S c h e m a + " . + fn.Name); item.SubItems.Add("Function"); "




//enumerate user views if (viewList) { foreach (Microsoft.SqlServer.Management.Smo.View vw in database.Views) { if (!vw.IsSystemObject) //show only user objects

  • -


Document info
Document views15
Page views15
Page last viewedWed Oct 26 10:22:01 UTC 2016