2012年3月22日星期四

Anybody played with SmoBrowser example within smo?

I was looking at the smo examples that come with sql server 2005/VS 2005

and I have found quite interesting how it was neat and easy to load everthing in a treeview using reflection.

I come to my question:

I would like to load a treeview control that I could reuse in the same way but depending on the needs i would like only to load certain stuff not all of them.

EG (Not all objects but just DatabaseCollection,TableCollection)

Is there a way I can ovverride IsExpandablePropertyType so that i can decide what i can load?

any suggestions

I have adopted the SMOBrowser source code to upgrade one our products, SQL2000Print that prints SQL Server 2000 object information using DMO. The new product will do the same for SQL Server 2005 using SMO. I load the treeview only with the database objects that I want to load, and in a structure that is similar to Microsoft SQL Server Management Studio.

I have uploaded a development version to our website (here is the download link http://www.starprint2000.com/downloads/beta/sqlserverprint2005.msi) that prints Tables, Views and Stored Procedures from SQL Server 2005. You are welcome to download it and try it.

If you want to load your treeview the same/simliar way please let me know, I will be happy to share the code for loading the Treeview.

Regards,

Joginder Nahil
www.starprint2000.com

|||

Hi there

thanks for your reply.I would be extremely grateful if you could share the code for the treeview .

you can email it at vbjunkie@.hotmail.co.uk and let me know.

Thanks a lot

|||

I have modified the SMOBrowser example, that you download using the following link, to demonstrate how you can load the treeview with the datbase objects of your choice.

http://www.starprint2000.com/downloads/SmoBrowser.zip

The zip file contains readme.doc that documents the changes and provides information showing how I loaded the Treeview using XML to my own tree structure.

Regards,

Joginder Nahil
www.starprint2000.com

|||

Thanks a lot for your link.

One last question.In one scenario I just wanted to load one database,not all of them.

Can i do that?

thanks again

|||

I have modified the SMOBrowser example, that you download using the following link, to demonstrate how you can load the treeview with the database objects of your choice AND only the database in the list:.

http://www.starprint2000.com/downloads/SmoBrowserDBOnly.zip

I have modified the code for procedure PopulateCollectionItems to check if the item to be loaded is a Database object and its name is in the list of names to be loaded.

Private Sub PopulateCollectionItems(ByVal node As TreeNode)
Dim oldCursor As Cursor = Me.Cursor
Me.Cursor = Cursors.WaitCursor
Try
For Each item As Object In CType(node.Tag, ICollection)
Select Case TypeName(item)
Case "Database"
If DatabasesToLoadList.Contains(CType(item, Database).Name) Then
node.Nodes.Add(CreateNode(item))
End If
Case Else
node.Nodes.Add(CreateNode(item))
End Select
Next
Finally
Me.Cursor = oldCursor
End Try
End Sub

Regards,

Joginder Nahil
www.starprint2000.com

|||

I have modified the SMOBrowser example, that you download using the following link, to demonstrate how you can load the treeview with the database objects of your choice AND only the database in the list:.

http://www.starprint2000.com/downloads/SmoBrowserDBOnly.zip

I have modified the code for procedure PopulateCollectionItems to check if the item to be loaded is a Database object and its name is in the list of names to be loaded.

Private Sub PopulateCollectionItems(ByVal node As TreeNode)
Dim oldCursor As Cursor = Me.Cursor
Me.Cursor = Cursors.WaitCursor
Try
For Each item As Object In CType(node.Tag, ICollection)
Select Case TypeName(item)
Case "Database"
If DatabasesToLoadList.Contains(CType(item, Database).Name) Then
node.Nodes.Add(CreateNode(item))
End If
Case Else
node.Nodes.Add(CreateNode(item))
End Select
Next
Finally
Me.Cursor = oldCursor
End Try
End Sub

Regards,

Joginder Nahil
www.starprint2000.com

|||

Fantastic!!

Thanks a lot for your very good reply and quick answer!

没有评论:

发表评论