PLease help!!!!!
How the ... do i fill my dataset with data using sql server, datatable, and adapter...

I've passed the select statement [ Select * from [TableName] and a ref of my datagrid to this procedure.

Public Sub FillDataGrid(ByRef DataGrid As DataGrid, ByVal SelectCommand As String)

Try

Dim adSQLAdapter As New SqlDataAdapter(SelectCommand, mSQLConnection)
Dim commands As New SqlCommandBuilder(adSQLAdapter)
Dim dtTable As New DataTable()

'POPULATE THE DATATABLE WITH DATA.
adSQLAdapter.Fill(dtTable)
DataGrid.DataSource = dtTable

Catch ex As Exception
CreateErrLog(ex.ToString)
End Try
End Sub

Nevermind...after laying in bed i realized that i needed to send a BYVAL reference and not BYRef. Sorted....Thanks myself!!!!

PLease help!!!!!
How the ... do i fill my dataset with data using sql server, datatable, and adapter...

I've passed the select statement [ Select * from [TableName] and a ref of my datagrid to this procedure.

Public Sub FillDataGrid(ByRef DataGrid As DataGrid, ByVal SelectCommand As String)

Try

Dim adSQLAdapter As New SqlDataAdapter(SelectCommand, mSQLConnection)
Dim commands As New SqlCommandBuilder(adSQLAdapter)
Dim dtTable As New DataTable()

'POPULATE THE DATATABLE WITH DATA.
adSQLAdapter.Fill(dtTable)
DataGrid.DataSource = dtTable

Catch ex As Exception
CreateErrLog(ex.ToString)
End Try
End Sub

Try this

Public Function GetRecordDB(ByVal table As String) As DataSet
        Dim con As SqlConnection = GetconnectionDB()

        Try
            Dim query As String = "SELECT * from " & table
            Dim ds As New DataSet
            Dim da As SqlDataAdapter = New SqlDataAdapter(query, con)
            Try
                da.Fill(ds, table)
            Finally
                da.Dispose()
            End Try
            Return ds
        Finally
            con.Close()
        End Try
    End Function

Then u can call this method from your Form_Load Event as follows

Dim ds As DataSet
ds = SqlDB.GetRecordDB("tablename")
        Me.dgAdmin.DataSource = ds
        Me.dgAdmin.DataMember = "admission"
        dgAdmin.ReadOnly = 1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.