Hi, i have this query:
cmd.CommandText = "SELECT DISTINCT PaperNo,ModuleCode1,ModuleCode2,ModuleCode3, ModuleCode4, ModuleCode5, ModuleCode6, ModuleCode7, ModuleCode8, ModuleCode9 FROM(PapersList)ORDER BY PaperNo ASC"
and i have this code to loop:
Dim dt3 As New DataTable
dt3.Columns.Add("AdminNo", GetType(String)) '/*Add column AdminNo
dt3.Columns.Add("PaperNo", GetType(Integer))
Dim curmodule As String = String.Empty
For Each dr2 As DataRow In dt2.Rows
curmodule = dr2("ModuleCode1").ToString
For Each dr1 As DataRow In dt1.Rows
If curmodule = dr1("ModuleCode").ToString Then
Dim dt3row As DataRow
dt3row = dt3.NewRow
dt3row("AdminNo") = dr1("AdminNo")
dt3row("PaperNo") = dr2("PaperNo")
dt3.Rows.Add(dt3row)
Me.DataGridView3.DataSource = dt3
End If
Next
Next
in this line:
curmodule = dr2("ModuleCode1").ToString
its only checking the first column in my datatable 2 i supposed.
However, i have got 9 Columns of modulecode.
i want to check for 1 modulecode in dt1, whether it is present in any of the columns in each row of dt2.
How can i edit this? Thanks!
my dt1 looks like:
AdminNo ModuleCode
111411H EG1001
183728V EG3920
111411H EG1919
dt2 which looks like:
paperNo ModuleCode1 ModuleCode2 ModuleCode3 ModuleCode 4 ..... ModuleCode9
1 EG1001 EG1010
2 EG1919 EG1001 EG1293 EG1032
3 EG3920
4 EG3891
so on and so forth.