Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-11-03 : 08:06:55
|
| mymatrix writes "Hi,I am using vb.net as front End and Sql Server2000 SP4 as back end.I need to populate list of Sql Servers available on my network in combobox (Just the name of server).For this i wrote code as: Private Function GetServerList() As DataTable Dim dtTable As New DataTable() Dim dcol As New DataColumn() Dim dr As DataRow Dim oSQLServerDMOApp As New SQLDMO.ApplicationClass() Dim oNameList As SQLDMO.NameList Dim sSvrName As String = String.Empty Dim obj As Object Try dcol.DataType = System.Type.GetType("System.String") dcol.AllowDBNull = False dcol.Caption = "Server" dcol.ColumnName = "Server" ' Add the column to the table. dtTable.Columns.Add(dcol) oNameList = oSQLServerDMOApp.ListAvailableSQLServers For Each obj In oNameList sSvrName = obj.ToString If sSvrName.Trim.Length > 0 Then If sSvrName.Trim.ToUpper = "(LOCAL)" Then sSvrName = "localhost" End If dr = dtTable.NewRow dr("Server") = sSvrName dtTable.Rows.Add(dr) End If Next Catch ex As Exception MsgBox(ex.ToString) End Try Return dtTable End FunctionI am returning a datatable which I used to populate Combo Box.But i am getting an error on below specified statement:oNameList = oSQLServerDMOApp.ListAvailableSQLServersError: Run-time exception thrown : System.InvalidCastException - QueryInterface for interface SQLDMO.NameList failed.Can Any body help me out to solve this error???Thanks in Advance" |
|
|
|
|
|