Connection Properties Dialog Box?

D

DaveS

Hi! I am creating a Windows app in VS2005 which will allow the user to
choose from different SQL data sources. I could hardcode a selection of
connection strings, but I'd rather not (in case a new database is
created, etc.). I'd like to use the common dialog box which appears
when you navigate to Project Properties > Settings

Select Type=(Connection String), then click in the cell in the Value
column. A Connection Properties dialog opens up. If anyone knows how
to programmatically access this dialog box, I'd really appreciate it!
I've been looking all over the place for it!!!

TIA,

DaveS
 
J

jvb

I built something in VS2003 that uses SQLDMO to get a list of servers
and then once authenticated on that server, a list of the databases
that are on that server and tables in the database. I do not know if
there is anything built into VS that will give you access to that
dialog.

Make sure you have a reference to DMO in your project. Your network
security may also prevent this from working. This snipet below gets the
SQL servers on your network. If this works for you, i can post the rest
of the code, didnt want to clog up the thread if it isn't going to work
for you in VS2005!

Hope this helps or at least points you in a good direction!

Private Sub LoadSQLServers(Optional ByVal ObjToFill As Object =
Nothing)

Dim SQLDMO As New SQLDMO.Application
Dim List As SQLDMO.NameList
Dim SQLServerName As Object
Dim i As Integer
Dim SQLServers() As String

Try

List = SQLDMO.ListAvailableSQLServers
Catch ex As Exception
MsgBox(Err.Number & vbCrLf & vbCrLf & Err.Description &
vbCrLf & vbCrLf)

MsgBox("Unable to generate list of available SQL Servers."
& vbCrLf & "Check your network connections " & _
"try again.", MsgBoxStyle.Critical + MsgBoxStyle.OKOnly,
_
"SQL Server Location Error")
Exit Sub
End Try

ReDim SQLServers(List.Count)

'ObjToFill is assumed to be a list type control
ObjToFill.items.clear()

For Each SQLServerName In List : i += 1
SQLServers(i) = (List.Item(i))
If Not ObjToFill Is Nothing Then
ObjToFill.items.add(SQLServers(i))
End If
Next

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top