Loading SQL results into grid headers
Posted on 2012-03-22
I am using the attached code to grab a list of suppliers. With the code I have it loads the results horizontally into the left most cells, I would like these to go across the top of Row1 as column names. Is this possible? Im thinking I may have to load them into an array and then loop thru the array inserting into the grid?
Private Sub LoadSuppliers()
Dim LoadVendorconn As New SqlConnection("")
Dim LoadVendorstrSQL As String = "SELECT * FROM Suppliers ORDER BY Supplier"
Dim LoadVendorda As New SqlDataAdapter(LoadVendorstrSQL, LoadVendorconn)
Dim LoadVendordt1 As New DataTable
LoadVendorconn.Open() 'Open the connection
Dim NewArray As String = LoadVendorda
.DataSource = LoadVendordt1