[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 158
  • Last Modified:

how to create a temp table and store it as a global variable? (easy points)

hi all,
I have the following code:

  Private Sub cmdMiscellaneous_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdMiscellaneous.Click

        Dim dt As New DataTable
        dt = com.library.data.Tools.GetTableMaintenace()
        Dim dtrw As DataRow
        dtrw = dt.Rows(0)
        For Each dtrw In dt.Rows
            Dim pattern As String = "T\d{2}"
            For Each m As Match In Regex.Matches(strRights, pattern)
                If dtrw(3) = m.Value Then
                    MsgBox("Table Name: " & dtrw(2) & vbCrLf & "Form Name: " & dtrw(4))
                 End If
            Next
        Next

    End Sub

and what i need to do is to create a tmp datatable and store as a global variable for this i have set up a global variable called:

Public dtTemp As DataTable

how can i do this?
thanks,
jsctechy
0
jsctechy
Asked:
jsctechy
  • 2
  • 2
1 Solution
 
Bob LearnedCommented:
Create table and columns:

dtTemp = New DataTable("Matches)
dtTemp.Columns.Add("TableName")
dtTemp.Columns.Add("FormName")

Add a row:

 If dtrw(3) = m.Value Then
    Dim dr As DataRow = dtTemp.NewRow()
   dr("TableName") = dtrw(2)
   dr("FormName") = dtrw(4)
    dtTemp.Rows.Add(dr)
End If

Bob
0
 
jsctechyAuthor Commented:
so this code goes instead of the msgbox()  
????
0
 
jsctechyAuthor Commented:
also how can i display the values that dttemp holds after the execution?
0
 
Bob LearnedCommented:
Yes, no MsgBox.

For Each dr As DataRow In dtTemp.Rows
   For Each dc As DataColumn In dtTemp.Columns
      Console.WriteLine(dr(dc).ToString())
   Next dc
Next dr

Bob
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now