Hello,
I have a load of tabs in a tab control, named tcCulprit.
In each tab there is a DataGridView, if the tab is named BM401582 the DataGridView is named dgBM401582.
I need all the DataGridViews to be populated with data from my database.
I have written the following code to try and do this
How can I then use the variable tabname to then set the corresponding DataGridViews data source???
Thanks for looking!
I have a load of tabs in a tab control, named tcCulprit.
In each tab there is a DataGridView, if the tab is named BM401582 the DataGridView is named dgBM401582.
I need all the DataGridViews to be populated with data from my database.
I have written the following code to try and do this
Code:
EmpNumber = cbTestEmp.SelectedValue
Dim TabCount As Integer = tcCulprit.TabCount - 1
Dim TabName As String
Do While TabCount > -1
tcCulprit.SelectTab(TabCount)
TabName = tcCulprit.SelectedTab.Name
con.ConnectionString = "Provider=Microsoft.Ace.OLEDB.12.0;Data Source=C:/Unit2.accdb"
sql = "Select Prod, Subassy, OpNumber, Competence, DateAchieved, Stage From Skills Where EmpNo = " & EmpNumber & " and Subassy = 'BM401600' "
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "'" & TabName & "'")
If ds.Tables("'" & TabName & "'").Rows.Count > 0 Then
TabName = ("dg" & TabName & "")
'This is where I want to set the DataGridView data source using the variable TabName to select the correct DataGridView
End If
Loop
Thanks for looking!