Hi,
I hope you get the idea.
Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim SelectStatement As String ' 2.
The SelectStatement Used for SQL
Dim NorthwindDataReader As SqlDataReader ' 3.
The Datareader that will return from the DataAccess Object
Dim Con As String =
System.Configuration.ConfigurationManager.AppSetti ngs("Northwind")
SelectStatement = "Select * From AccountsTable"
'Instantiate the Data Access Oject
Dim localSQLServer As New DataServer(Con)
'Call the runSQLDataSet Function that takes the SQL String, an
optional Table name and returns the DataSet
NorthwindDataReader =
localSQLServer.runSQLDataReader(SelectStatement)
'We can now populate the Grid with the returning DataSet's
DataTable
'DataGridView1.DataSource = NorthwindDataReader
'DataGridView1.DataBindings()
If NorthwindDataReader.Read = True Then
TextBox1.Text = NorthwindDataReader(0)
TextBox2.Text = NorthwindDataReader(1)
End If
Dim intCol As Integer
With NorthwindDataReader
If .HasRows Then
DataGridView1.Rows.Clear()
'Add column definition: FieldName, and ColumnName
For intCol = 0 To .FieldCount - 1
DataGridView1.Columns.Add(.GetName(intCol),
GetName(intCol))
Next
'Base column width on header text width
DataGridView1.AutoSizeColumnsMode = _
DataGridViewAutoSizeColumnsMode.ColumnHeader
While .Read
'Get row data as an Object array
Dim objCells(intCol) As Object
GetValues(objCells)
'Add an entire row at a time
DataGridView1.Rows.Add(objCells)
End While
End If
End With
End Sub
--
bhar
------------------------------------------------------------------------
Posted via
http://www.codecomments.com
------------------------------------------------------------------------