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

Recommended Answers

All 3 Replies

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])
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.