Try
'========================================= ADO INSTANTIATION ===================================================
Dim cmdSelect As New SqlCommand
Dim thisDataSet As New DataSet
Dim pSQL_Conn As New SqlConnection 'CONNECTION OBJECT
Dim cmdInsert As New SqlCommand 'COMMAND OBJECT TO PERFOM QUERIES SUCH AS INSERT, UPDATE AND SELECT
Dim pSQL_Adapter As New SqlDataAdapter 'DATA ADAPTER TO PERFORM ACTUAL CHANGES TO DATABASE
'===============================================================================================================
'ASSIGNS CONNECTION STRING TO THE CONNECTION STRING OBJECT. IT USES A GLOBAL VARIABLES WHICH GETS IT VALUE
'FROM THE SPLASH SCREEN. THIS IS IN CASE WE MIGRATE TO ANOTHER SERVER URL ALL WE HAVE TO DO IS CHANGE
'THE TEXT FILE LOCATED IN THE ATP ASSISTANT SERVER
'--------------------------------------------------------------------------------------------------------------- pSQL_Conn.ConnectionString =
"Data Source=MSSQL1\SERVER;Integrated Security=True;Initial Catalog=ATP_Data;Connection Timeout=30"
'ASSIGNS SQL STATEMENT TO THE COMMAND OBJECT cmdSelect.CommandText =
"SELECT * FROM tblTableName"
'ASSIGNS CONNECTION STRING TO THE CONNECTION OBJECT cmdSelect.Connection = pSQL_Conn
'ASSIGNS COMMAND TEXT OBJECT TO THE DATA ADAPTER pSQL_Adapter.SelectCommand = cmdSelect
'=============================================================================================================== pSQL_Conn.Open()
'OPENS THE CONNECTION TO DATABASE STATED ON THE CONNECTION STRING
Dim sqlBuilder As New SqlCommandBuilder(pSQL_Adapter) 'INSTANTIATE NEW BUILDER AND ASSIGNS THE ADAPTER
'=============================================================================================================== pSQL_Adapter.Fill(thisDataSet,
"MyTable") 'FILLS DATA SET
'=============================================================================================================== MsgBox(thisDataSet.Tables(
"MyTable").Rows(0)("fldCompletionDate").ToString)' Set up the DataGridView.
With Me.DataGridView2' Automatically generate the DataGridView columns. .AutoGenerateColumns =
True
' Set up the data source.
'bindingSource1.DataSource = thisDataSet .DataSource = thisDataSet
' Automatically resize the visible rows. .AutoSizeRowsMode = _
DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders' Set the DataGridView control's border. .BorderStyle =
BorderStyle.Fixed3D' Put the cells in edit mode when user enters them. .EditMode =
DataGridViewEditMode.EditOnEnterEnd With
Catch ex As SqlExceptionMsgBox(ex)
End Try