Hi all,,

When I open a form where I refer to a public connection string, Visual studio tells me: The Variable 'JMSConnection' is either undeclared or was never asigned.

The line which gives this is:

VB Code:
  1. Me.SQLCon1.ConnectionString = JMSGlobals.JMSConnection.ConnectionString

The connection string in the globals module is:

VB Code:
  1. Module JMSGlobals
  2.     Public JMSColor = Color.FromArgb(149, 178, 198)
  3.     Public JMSConnection As New SqlConnection
  4.  
  5. End Module

The connection string gets built in the login form and looks like:



VB Code:
  1. Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogin.Click
  2.  
  3.         If (RdoSQLAuth.Checked = True) Then
  4.             'JMSGlobals.JMSConnection.ConnectionString = "Server=" & Me.txtJMSServer.Text & ";Database=MSTRIBOLOGY;User ID=" & Me.txtUsername.Text & ";Password=" & Me.txtPassword.Text & ";Trusted_Connection=False;workstation id=" & Environment.MachineName & ";"
  5.             JMSGlobals.JMSConnection.ConnectionString = "Data Source=" & Me.txtJMSServer.Text & ";Initial Catalog=MSTRIBOLOGY;User Id=" & Me.txtUsername.Text & ";Password=" & Me.txtPassword.Text & ";Application Name=" & Application.ProductName & " " & Application.ProductVersion & ";"
  6.             Me.DialogResult = DialogResult.OK
  7.             'Me.Close()
  8.  
  9.         ElseIf (RdoNTAuth.Checked = True) Then
  10.             JMSGlobals.JMSConnection.ConnectionString = "Data Source=" & Me.txtJMSServer.Text & ";Initial Catalog=MSTRIBOLOGY;Integrated Security=SSPI;workstation id=" & Environment.MachineName & ";Application Name=" & Application.ProductName & " " & Application.ProductVersion & ";"
  11.             Me.DialogResult = DialogResult.OK
  12.             'Me.Close()
  13.         End If
  14.  
  15.     End Sub

Anyone know where my problem might be?

Thanks

Rudi