emaduddeen
Well-known member
- Joined
- May 5, 2010
- Messages
- 171
- Location
- Lowell, MA & Occasionally Indonesia
- Programming Experience
- Beginner
Hi Everyone,
Can data connections, data adapters, data sets, etc be placed in a global location?
Many of my forms have code like this:
Is there any way to get all of this code in a central location so this stuff can be access from other forms?
If the answer is yes could you show some sample code and instruction on how to do it?
Thanks.
Truly,
Emad
Can data connections, data adapters, data sets, etc be placed in a global location?
Many of my forms have code like this:
VB.NET:
' Declare a DataAdapter for the DataTable.
'-----------------------------------------
Dim objDataAdapter As OleDbDataAdapter
' Declare a DataTable object to hold data from the SQL query.
'------------------------------------------------------------
Dim objDataTable As DataTable
' Declare a DataSet.
'-------------------
Dim objDataSet As New DataSet
' Declare a DataReader.
'----------------------
Dim objDataReader As OleDbDataReader
' Declare a connection object.
'-----------------------------
Dim objConnection As OleDbConnection = Nothing
' Command object to be used in select, insert, delete and update statements.
'---------------------------------------------------------------------------
Dim objCommand As OleDbCommand
Public Sub New()
InitializeComponent()
' Create the connection object to use an SQL query and open it.
'--------------------------------------------------------------
objConnection = New OleDbConnection(My.Settings.ISGLConnectionString)
objConnection.Open()
' Create a DataTable object to hold data from the SQL query.
'-----------------------------------------------------------
objDataTable = New DataTable()
' Create a DataAdapter object for the DataTable.
'-----------------------------------------------
objDataAdapter = New OleDbDataAdapter(strSqlStatement, objConnection)
End Sub
Is there any way to get all of this code in a central location so this stuff can be access from other forms?
If the answer is yes could you show some sample code and instruction on how to do it?
Thanks.
Truly,
Emad