Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27468

[RESOLVED] setting DataGridView datasource by TabName

$
0
0
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

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

How can I then use the variable tabname to then set the corresponding DataGridViews data source???


Thanks for looking!

Viewing all articles
Browse latest Browse all 27468

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>