Link to home
Start Free TrialLog in
Avatar of Tom Knowlton
Tom KnowltonFlag for United States of America

asked on

Add HashTable as Value inside another Hashtable

How can I reuse htFields inside the For Each loop?

I want to add htFields as the value for the matching key inside htTables




    dim htTables as New Hashtable()

    for each str as String in GetTableNames(conn)
      debug.WriteLine(str)
      htTables.Add(str,Nothing)
      conn.Open
      Dim cmd1 As OleDb.OleDbCommand = New OleDb.OleDbCommand("select * from " & str, conn)
      Dim dra As IDataReader = cmd1.ExecuteReader(CommandBehavior.SchemaOnly Or CommandBehavior.KeyInfo)
      Dim dta As DataTable = dra.GetSchemaTable()
      Dim myrow As DataRow
      For Each myrow In dta.Rows
        Debug.WriteLine("Column Name:  " + myrow(0).ToString)
        dim htFields As New Hashtable()
        htFields.Add(myrow(0).ToString(),false)
      Next
      htTables(str) = htFields

      htFields = Nothing
      dra.Close
      conn.Close
    Next
ASKER CERTIFIED SOLUTION
Avatar of Solar_Flare
Solar_Flare

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tom Knowlton

ASKER

That was it, thanks.