Enumerate Server and Database List.
-
Monday, November 19, 2012 6:49 AM
I have created a Application which shows the List of available SQL Server on Network and Database List.
But, the application shows only Server Name on the Remote PC. Does not show the Database...
On Local PC on which I am Running SQL Server 2008, it shows both the Server List and the Database of that Server....
So kindly please help me.....
This is my Code....
Imports Microsoft.SqlServer
Imports Microsoft.SqlServer.Server
Imports Microsoft.SqlServer.Management
Imports Microsoft.SqlServer.Management.Smo
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim datatable = SmoApplication.EnumAvailableSqlServers(False)
ComboBox1.ValueMember = "Name"
ComboBox1.DataSource = datatable
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
ComboBox2.Items.Clear()
If ComboBox1.SelectedIndex <> -1 Then
Dim serverName As String = ComboBox1.SelectedValue.ToString()
Dim server As Server = New Server(serverName)
Try
For Each database As Database In server.Databases
ComboBox2.Items.Add(database.Name)
Next
Catch ex As Exception
Dim exception As String = ex.Message
End Try
End If
End Sub
End ClassA Form Has a two Combobox.......
Please Help me.
All Replies
-
Monday, November 19, 2012 10:08 AM
-
Tuesday, November 20, 2012 8:07 AM
Thank You, For interesting......
I don't know much about it, But I have a two PC, which are connected via Modem.....
And on which PC I have Installed a SQL Server 2008 on this PC the Application shows the both Server List and Database... But the other PC while I run the Application on it, its only shows the Server List, but does not shows any database.....Can you help me via a Team Viewer....or even i can Call You....
I am from india...but I really want to do it.. So, please help me..
-
Tuesday, November 20, 2012 8:11 AM
I have installed SQL Server 2008 only on one PC.... Which acts as Server and the other access the data from the Server... via LAN.
If I create an Application and Fires the Query with predefined Connection String.... than my Application is running very Fine....
My Purpose for above question is, I want to modify the connection string on run time.....
-
Wednesday, November 21, 2012 6:26 AMPlease Help.......
-
Wednesday, November 21, 2012 7:21 AM
-
Wednesday, November 21, 2012 12:32 PM
No, No exception occurs....
but on my second PC its not showing the database list only shows the server... and on my main PC where I installed a SQL Server it run perfectly.....
-
Wednesday, November 21, 2012 12:52 PM
This is a SQL Server PC where Application Shows the Database List...
This is a Remote PC where it shows only Server List...
Both are connected via LAN..... From my Router + Modem .......
Please Help Me...
-
Thursday, November 22, 2012 4:49 PM
Have you debugged your app, if everything works? Does the logon really works, do you get informations of the server, like the name.
Modem/Router?!; are both machines in the same domain and do you login with an domain account, which do have permissions in SQL Server?
Olaf Helper
Blog Xing- Marked As Answer by Iric WenModerator Tuesday, November 27, 2012 9:16 AM
- Unmarked As Answer by Iric WenModerator Tuesday, November 27, 2012 9:16 AM
-
Saturday, November 24, 2012 4:19 AMNo, I am not log in into a domain, I just disable the SQL Severer Windows Firewall.......
and I don't know much about Log in in to a SQL Server... -
Saturday, November 24, 2012 7:02 AM
With your code, you logon to SQL Server with your Windows account; in a domain this works pretty well, but not in a workgroup. You have to create a SQL account and have to use this to get it work; as I already wrote, the login requires permission to logon and query the existing databases.Olaf Helper
Blog Xing- Marked As Answer by Iric WenModerator Tuesday, November 27, 2012 9:16 AM
-
Monday, November 26, 2012 10:26 AMYup, Thank You....

