Вот что я использую:
Friend Sub connect(ByVal isDebuggerAttached As Boolean)
Dim server As String
Dim dbName As String
If isDebuggerAttached Then
server = "DHSDEV10069\DSD"
Else
server = "dhs10073sql"
End If
dbName = "DSDWorkPlanTracking"
_connect = "Data Source=" & server & ";Database=" & dbName & ";Integrated Security=true"
_connect = _connect & ";Application Name = " & My.Application.Info.AssemblyName
End Sub
и в классе вызова:
Try
Model.instance.connect(System.Diagnostics.Debugger.IsAttached)
Catch ex As Exception
MsgBox("Sorry, couldn't connect to database " & ex.Message)
End Try
Кроме того, для справки / О программе:
Private Sub mnuHelpAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuHelpAbout.Click
Dim msg As String
Dim appName As String
If My.Application.Info.Title <> "" Then
appName = My.Application.Info.Title
Else
appName = System.IO.Path.GetFileNameWithoutExtension(My.Application.Info.AssemblyName)
End If
msg = appName & vbCrLf & vbCrLf
msg = msg & "Version: " & Application.ProductVersion & vbCrLf & vbCrLf ' the file version displayed in .exe properties. Assembly version is for internal builds and doesn't need to change for one developer.
msg = msg & "User: " & My.User.Name & vbCrLf & vbCrLf
msg = msg & "Connection: " & Model.instance.connection & vbCrLf & vbCrLf
MsgBox(msg, MsgBoxStyle.OkOnly, appName)
End Sub