This is working for me for exporting DataSet to SQLite:
$Data = <your DataSet>
$SQLiteConnection = [System.Data.SQLite.SQLiteConnection]::new('DataSource=:MEMORY:')
$SQLiteConnection.Open()
[System.String[]]$tableNames = $Data.Tables.TableName
foreach ($table in $tableNames) {
$columnDefinitions = @()
foreach ($column in $Data.Tables[$table].Columns) {
# Ought to create mapping between Types and DBTypes AnsiString, Binary, Byte, Boolean, Currency, Date, DateTime, Decimal, Double, Guid, Int16, Int32, Int64, Object, SByte, Single, String, Time, UInt16, UInt32, UInt64, VarNumeric, AnsiStringFixedLength, StringFixedLength, Xml, DateTime2, DateTimeOffset
$columnDefinitions += ($column.ColumnName + ' ' + $column.DataType.Name)
}
$sqliteCommand = $SQLiteConnection.CreateCommand()
$sqliteCommand.CommandText = 'CREATE TABLE IF NOT EXISTS ' + $table + ' (' + [System.String]::Join(', ', $columnDefinitions) + ')'
$rowsAffected = $sqliteCommand.ExecuteNonQuery()
$InsertCommand = 'INSERT INTO ' + $table + ' (' + [System.String]::Join(', ', $Data.Tables.Columns.ColumnName) + ') VALUES (:' + [System.String]::Join(', :', $Data.Tables.Columns.ColumnName) + ')'
$sqliteDataAdapter = [System.Data.SQLite.SQLiteDataAdapter]::new($SQLiteConnection)
$sqliteDataAdapter.MissingSchemaAction = [System.Data.MissingSchemaAction]::AddWithKey
$sqliteDataAdapter.InsertCommand = [System.Data.SQLite.SQLiteCommand]::new($InsertCommand, $SQLiteConnection)
foreach ($column in $Data.Tables[$table].Columns) {
$null += $sqliteDataAdapter.InsertCommand.Parameters.Add($column.ColumnName, $column.DataType.Name, $column.MaxLength, $column.ColumnName)
}
$rowsAffected = $sqliteDataAdapter.Update($Data, $table)
}