HI ST1,
This snippet should give you what you need:
#Region "Dictionary To DataTable"
'------------------------------------------------------------------------------------------------------------
'Referenced Code: DictionaryToDataTable -> DataTable
'
'Description: Converts Dictionary(Of String, String) to DataTable from Dictionary where column = Key and row = Value
'
'Notes:
'
'Usage:
'
'Created By: OneStream
'Date Created: 04-04-2023
'------------------------------------------------------------------------------------------------------------
Public Function DictionaryToDataTable(ByVal si As SessionInfo, ByVal dictParam As Dictionary(Of String, String)) As DataTable
' Method name
Dim methodName As String = System.Reflection.MethodInfo.GetCurrentMethod().Name
' Object to return
Dim dt As New DataTable()
Try
' Add columns (Keys)
dt.Columns.AddRange(dictParam.Keys.ToList().Select(Function(lambda) New DataColumn(lambda, GetType(String))).ToArray())
' Add row (Values)
dt.Rows.Add(dictParam.Values.ToArray())
' Return
Return dt
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(ex))
End Try
End Function
#End Region