The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine

Sushil Agarwal 381 Reputation points

I am having Windows 64 Bit os build 19043.1826 21H1, i have office 21 64 bit on this pc, but when i want to open an xls file i am getting the above error,
if i build application 32bit it open file correctly, but if i make it 64 bit i can not install Microsoft.Jet.OLEDB.4.0 .

how to handle this situation, is making app 32 bit is the only solution ?, what i loose making it 32 bit ? my pc has got 16gb ram

       switch (filextntn)  
                        case ".XLS":  
                            strExcelCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ofn.FileName +  
                                    ";Extended Properties=\"Excel 8.0;HDR=YES;IMEX=1\"";  
                        case ".XLSX":  
                            strExcelCon = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + ofn.FileName + ";Extended Properties=\"Excel 12.0 Xml;HDR=YES\"";  
                        case ".XLSB":  
                            strExcelCon = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + ofn.FileName + ";Extended Properties=\"Excel 12.0;HDR=YES\"";  
                        case ".XLSM":  
                            strExcelCon = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + ofn.FileName + ";Extended Properties=\"Excel 12.0 Macro;HDR=YES\"";  
                        case ".TXT":  
                            //EDITL.txt for BAJAJ  
                            strExcelCon = " File Type:" + filextntn;  

if i change the connectiong string to "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + ofn.FileName + ";Extended Properties=\"Excel 12.0;HDR=YES\""; to open an xls file it is also giving error and reading it correctly.

how to solve this issue

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,863 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jack J Jun 24,476 Reputation points Microsoft Vendor

    @Sushil Agarwal , Welcome to Microsoft Q&A, based on my test, I reproduced your problem.

    According to my research, Please try the following steps to access excel file without the exception.

    First, Please install the software Microsoft Access Database Engine 2010 Redistributable.

    Second, you could try the following connection string to open a xls file.

    "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path+ ";Extended Properties='Excel 12.0;HDR=NO;IMEX=1;'";  

    Finally, you could use the above connection string to access the excel file.

    Note: Based on my further test, the above code works both in 32 bit app or 64 bit app.

    Hope the above steps could help you.

    Best Regards,

    If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    2 people found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. vinod gaikwad 0 Reputation points

    User's image

    0 comments No comments