سؤال

I run OLE DB enumerator in powershell cmd prompt and see that "Microsoft.ACE.OLEDB.12.0" is listed. However, when I run the program which needs to use the OLE DB Provider, it gives the error: "The Microsoft.ACE.OLEDB.12.0 Provider is not registered on the local machine. Can someone tell me why it can not find the provider when it is already there.

I downloaded Microsoft Database Access Engine 2010 Redistributible and still have the same error

    $filepath = 'C:\Users\raoashw\Documents\Incident_Dimension_and_Fact Tables\Incident_Time_Dimension_Table.xlsm'
    $connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=`"$filepath`";Extended Properties=`"Excel 12.0 Macro;HDR=YES`";"
    $qry= 'select * from [backupset$]'
    $sqlserver = 'c0003131.itcs.hp.com'
    $dbname = 'ads'
    $tblname = 'ExcelData_Fill'
    function Get-ExcelData 
    {
        param($connString, $qry='select * from [Untitled$]')
        $conn = New-Object System.Data.OleDb.OleDBConnection($connString)
        $conn.open()
        $cmd = New-Object System.Data.OleDb.OleDbCommand($qry,$conn)
        $da = New-Object System.Data.OleDb.OleDbDataAdapter($cmd)
        $dt = New-Object System.Data.DataTable
        [void]$da.fill($dt)
        $conn.close()
        $dt


    }

    function Write-DataTableToDatabase 
    {
        param($dt,$destServer,$destDb,$destTbl)
        $connectionString = "Data Source=$destServer;Integrated Security=true; Initial         Catalog=$destdb;"
        $bulkCopy= New-Object ("Data.SqlClient.SqlBulkCopy") $connectionString
        $bulkCopy.DestinationTableName= "$destTbl"
        $bulkCopy.WriteToServer($dt)

    }

    $dt = Get-ExcelData $connString $qry
    Write-DataTableToDatabase $dt $sqlserver $dbname $tblname

Can someone please tell me how to fix this error?

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top