Click here to Skip to main content
14,450,530 members
   

C#

 
AnswerRe: compare two dictionay and display difference Pin
Gerry Schmitz18-Jan-20 7:40
mveGerry Schmitz18-Jan-20 7:40 
GeneralRe: compare two dictionay and display difference Pin
mjbaquiran18-Jan-20 8:08
Membermjbaquiran18-Jan-20 8:08 
GeneralRe: compare two dictionay and display difference Pin
Gerry Schmitz18-Jan-20 8:52
mveGerry Schmitz18-Jan-20 8:52 
AnswerRe: compare two dictionary and display difference Pin
BillWoodruff19-Jan-20 1:19
mveBillWoodruff19-Jan-20 1:19 
AnswerRe: compare two dictionary and display difference Pin
Richard Deeming20-Jan-20 8:52
communityengineerRichard Deeming20-Jan-20 8:52 
GeneralRe: compare two dictionary and display difference Pin
mjbaquiran20-Jan-20 20:53
Membermjbaquiran20-Jan-20 20:53 
GeneralRe: compare two dictionary and display difference Pin
Richard Deeming21-Jan-20 2:19
communityengineerRichard Deeming21-Jan-20 2:19 
QuestionOleDb Error Pin
Kevin Marois15-Jan-20 9:57
professionalKevin Marois15-Jan-20 9:57 
I have two apps. One converts an Access database into SQL. It uses the Microsoft.ACE.OLEDB.12.0' provider. This works fine.

My second app reads Excel files into SQL. It uses the same Microsoft.ACE.OLEDB.12.0' provider. However, when I run it, I get
'The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine

Access Conversion App
private void ConnectToAccess(string accessDB)
{
    try
    {
        connString = $"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={accessDB};Persist Security Info = False;";
        acccessConn = new OleDbConnection(connString);
        acccessConn.Open();
    }
    catch (Exception e)
    {
        MessageBox.Show(e.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
    }
}
Excel Conversion App
private static DataSet ToDataSet(string excelFile, int startRecord = 0, int maxRecord = -1, string condition = "")
{
    DataSet result = new DataSet();

    string connString = connString = $"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={excelFile};Extended Properties=Excel 12.0;HDR=No;IMEX=1";
    using (OleDbConnection connection = new OleDbConnection(connString))
    {
        try
        {
            connection.Open();  //==== THROWS HERE

            DataTable schema = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);

            foreach (DataRow drSheet in schema.Rows)
            {
                if (drSheet["TABLE_NAME"].ToString().Contains("$"))
                {
                    string s = drSheet["TABLE_NAME"].ToString();

                    if (s.StartsWith("'")) 
                    {
                        s = s.Substring(1, s.Length - 2);
                    }
                    var command =  new OleDbDataAdapter(string.Join("", "SELECT * FROM [", s, "] ", condition), connection);

                    DataTable dt = new DataTable();

                    if (maxRecord > -1 && startRecord > -1)
                    {
                        command.Fill(startRecord, maxRecord, dt);
                    }
                    else
                    {
                        command.Fill(dt);
                    }

                    result.Tables.Add(dt);
                }
            }

            return result;
        }
        catch (Exception ex)
        {
            throw;
        }
        finally
        {
            connection.Close();
        }
    }
}

How can this work for one and not the other??
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.

AnswerRe: OleDb Error Pin
OriginalGriff15-Jan-20 10:03
communityengineerOriginalGriff15-Jan-20 10:03 
GeneralRe: OleDb Error [UPDATED] Pin
Kevin Marois15-Jan-20 10:34
professionalKevin Marois15-Jan-20 10:34 
GeneralRe: OleDb Error Pin
OriginalGriff15-Jan-20 10:41
communityengineerOriginalGriff15-Jan-20 10:41 
GeneralRe: OleDb Error Pin
Kevin Marois15-Jan-20 11:57
professionalKevin Marois15-Jan-20 11:57 
GeneralRe: OleDb Error [UPDATED] Pin
Dave Kreskowiak15-Jan-20 10:45
mveDave Kreskowiak15-Jan-20 10:45 
GeneralRe: OleDb Error [UPDATED] Pin
Kevin Marois15-Jan-20 11:51
professionalKevin Marois15-Jan-20 11:51 
GeneralRe: OleDb Error [UPDATED] Pin
Eddy Vluggen15-Jan-20 13:15
professionalEddy Vluggen15-Jan-20 13:15 
GeneralRe: OleDb Error [UPDATED] Pin
Dave Kreskowiak15-Jan-20 13:50
mveDave Kreskowiak15-Jan-20 13:50 
GeneralRe: OleDb Error [UPDATED] Pin
Eddy Vluggen15-Jan-20 13:57
professionalEddy Vluggen15-Jan-20 13:57 
QuestionException Handling Question Pin
Kevin Marois14-Jan-20 19:53
professionalKevin Marois14-Jan-20 19:53 
AnswerRe: Exception Handling Question Pin
OriginalGriff14-Jan-20 22:19
communityengineerOriginalGriff14-Jan-20 22:19 
AnswerRe: Exception Handling Question Pin
F-ES Sitecore14-Jan-20 23:49
mveF-ES Sitecore14-Jan-20 23:49 
SuggestionRe: Exception Handling Question Pin
Richard Deeming15-Jan-20 1:38
communityengineerRichard Deeming15-Jan-20 1:38 
AnswerRe: Exception Handling Question Pin
Gerry Schmitz15-Jan-20 14:44
mveGerry Schmitz15-Jan-20 14:44 
QuestionHow to add text to a script tag at src using jQuery Pin
Member 1316600712-Jan-20 8:52
MemberMember 1316600712-Jan-20 8:52 
AnswerRe: How to add text to a script tag at src using jQuery Pin
OriginalGriff12-Jan-20 11:25
communityengineerOriginalGriff12-Jan-20 11:25 
Questioni need a c# project using interfaces about anything Pin
Ali Al Akbar Hachem12-Jan-20 5:23
MemberAli Al Akbar Hachem12-Jan-20 5:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.