0

Hi I m using datagrid my cloumns are coming dynamically.
Here is the attached view I m getting. For first column I get value from database. now for each cloumn I have to get values for which i have to traverse multiple records from database I want each cloumn should be populated in one shot. Please help me with arrays or list to use for that.

Thanks

2
Contributors
3
Replies
5
Views
6 Years
Discussion Span
Last Post by ShahanDev
0

Hi I m using datagrid my cloumns are coming dynamically.
Here is the attached view I m getting. For first column I get value from database. now for each cloumn I have to get values for which i have to traverse multiple records from database I want each cloumn should be populated in one shot. Please help me with arrays or list to use for that.

Thanks

Hi!

You should check OleDBDataAdapter Class and Fill DataSet. That DataSet will be used to populate Datagridview using DataSource property.

from this link:
http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbdataadapter%28v=vs.71%29.aspx

Public Function SelectOleDbSrvRows(dataSet As DataSet, connection As String, query As String) As DataSet
    Dim conn As New OleDbConnection(connection)
    Dim adapter As New OleDbDataAdapter()
    adapter.SelectCommand = new OleDbCommand(query, conn)
    adapter.Fill(dataset)
    Return dataset
End Function

use it like this:

Datagridview1.DataSource = SelectOleDbSrvRows([B]DataSetToFill[/B],[B]YourConnectionString[/B], [B]QueryORcmdTextForFilter[/B])
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.