I'm probably searching under the wrong things, because I can't find this one and I'm sure someone else has already asked this. If someone could point, I'd greatly appreciate it.
I'm using a SQL Management Object to backup databases on various SQL Servers. It's being coded via Visual Studio 2005 in VB .Net. Rather than recreate the program for every SQL Server we have, I'd like to open it up to user Input. Is there a way to do a Console.Readline() and pass it on to a ServerConnection object?
Or... is there a way to populate a list of currently available Servers so the user can just pick one?
I don't want to hard code the servers in because I'll be sharing this program with other departments who have their own servers and I don't want them messing with the guts of the program. Essentially, I'm thinking of a popup box a lot like the RemoteDesktop connection box where it keeps in memory your last few choices and allows you to enter a new one.
My current module is something like:
The commented out lines are where I tried to set it up to read a user String and failed miserably. I keep getting a NULLReferenenceException (Object reference not set to an instance of an object.) error.
As always, help is greatly appreciated. Even if you just point me to a few links.
Thanks,
Catadmin - MCDBA, MCSA
"No, no. Yes. No, I tried that. Yes, both ways. No, I don't know. No again. Are there any more questions?"
-- Xena, "Been There, Done That"
I'm using a SQL Management Object to backup databases on various SQL Servers. It's being coded via Visual Studio 2005 in VB .Net. Rather than recreate the program for every SQL Server we have, I'd like to open it up to user Input. Is there a way to do a Console.Readline() and pass it on to a ServerConnection object?
Or... is there a way to populate a list of currently available Servers so the user can just pick one?
I don't want to hard code the servers in because I'll be sharing this program with other departments who have their own servers and I don't want them messing with the guts of the program. Essentially, I'm thinking of a popup box a lot like the RemoteDesktop connection box where it keeps in memory your last few choices and allows you to enter a new one.
My current module is something like:
Code:
Module CreateInitialConnection
Public ProdServer As New Server()
Public ProdConn As ServerConnection
'Public MyServer As String
Public Sub CreateMyConnection()
'System.Console.Write("Enter your Server name and port number (if applicable) as <MyServer>, <port>: ")
' MyServer = System.Console.ReadLine()
ProdConn = ProdServer.ConnectionContext
ProdConn.ServerInstance = "<MyServer>, <MyPort>"
'If MyServer.ToString() = Nothing Then
' MsgBox("You must enter a proper SQL Server name to continue")
' Else
' ProdConn.ServerInstance = MyServer.ToString()
'End If
End Sub
End Module
The commented out lines are where I tried to set it up to read a user String and failed miserably. I keep getting a NULLReferenenceException (Object reference not set to an instance of an object.) error.
As always, help is greatly appreciated. Even if you just point me to a few links.
Thanks,
Catadmin - MCDBA, MCSA
"No, no. Yes. No, I tried that. Yes, both ways. No, I don't know. No again. Are there any more questions?"
-- Xena, "Been There, Done That"