For test purposes I use the #if DEBUG preprocessor directive to deliver the
connection strings etc for my local host configurations. The release version
has the live server. The code below shows the principle.
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
components = New System.ComponentModel.Container()
Me.Text = "Form1"
End Sub
#End Region
#If DEBUG Then
Sub foo(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
MessageBox.Show("DEBUG")
End Sub
#End If
#If Not Debug Then
Sub foo(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
MessageBox.Show("RELEASE")
End Sub
#End If
End Class
--
Bob Powell [MVP]
Visual C#, System.Drawing
Ramuseco Limited .NET consulting
http://www.ramuseco.com
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"Saladin" <ma****************@wave.co.nz> wrote in message
news:e1**************@TK2MSFTNGP10.phx.gbl...
Hello
I use a module to determine whether SQL connection is to my localhost or
to
my remote server. At moment, I enable either one or the other line of code
to switch between, then build, (then upload if publishing to remotre
server).
Trouble is, I'm forever forgetting to do the switch/build before uploading
so have to re-upload. Any suggestions as to how program can automatically
determine which code line to use? Try/Catch no good in module. Neither
have
I had success with server.mappath.
Thanks
Graeme