[RESOLVED] Why cant sqlConnection and sqlDataAdapter variables be global ?
Hi,
When I tried to create a global variable of type sqlConnection and sqlDataAdapter, vb 2005 underlines it and says that the "type is not defined".
The 2 declarations are:
Dim myConnection As SqlConnection = New SqlConnection(..........)
Dim myAdapter As SqlDataAdapter = New SqlDataAdapter(......,....)
When they are added as global variables (outside of any private sub), vb 2005 highlights sqlConnection and sqlDataAdapter as errors. But when they are added inside a private sub procedure, like Private Sub Form1_Load, then there is no error.
How come they cant be global variables? I need them to be freely accessed by the various Private Sub procedure inside the Form1 public class.
Re: Why cant sqlConnection and sqlDataAdapter variables be global ?
You are mistaken. You must be doing something else that you aren't mentioning, like trying to declare them in a file that hasn't imported the appropriate namespace.