Click here to Skip to main content
15,895,777 members
Home / Discussions / C#
   

C#

 
AnswerRe: compare two dictionay and display difference Pin
Gerry Schmitz18-Jan-20 6:40
mveGerry Schmitz18-Jan-20 6:40 
GeneralRe: compare two dictionay and display difference Pin
mjbaquiran18-Jan-20 7:08
mjbaquiran18-Jan-20 7:08 
GeneralRe: compare two dictionay and display difference Pin
Gerry Schmitz18-Jan-20 7:52
mveGerry Schmitz18-Jan-20 7:52 
AnswerRe: compare two dictionary and display difference Pin
BillWoodruff19-Jan-20 0:19
professionalBillWoodruff19-Jan-20 0:19 
AnswerRe: compare two dictionary and display difference Pin
Richard Deeming20-Jan-20 7:52
mveRichard Deeming20-Jan-20 7:52 
GeneralRe: compare two dictionary and display difference Pin
mjbaquiran20-Jan-20 19:53
mjbaquiran20-Jan-20 19:53 
GeneralRe: compare two dictionary and display difference Pin
Richard Deeming21-Jan-20 1:19
mveRichard Deeming21-Jan-20 1:19 
QuestionOleDb Error Pin
Kevin Marois15-Jan-20 8:57
professionalKevin Marois15-Jan-20 8: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 9:03
mveOriginalGriff15-Jan-20 9:03 
GeneralRe: OleDb Error [UPDATED] Pin
Kevin Marois15-Jan-20 9:34
professionalKevin Marois15-Jan-20 9:34 
GeneralRe: OleDb Error Pin
OriginalGriff15-Jan-20 9:41
mveOriginalGriff15-Jan-20 9:41 
GeneralRe: OleDb Error Pin
Kevin Marois15-Jan-20 10:57
professionalKevin Marois15-Jan-20 10:57 
GeneralRe: OleDb Error [UPDATED] Pin
Dave Kreskowiak15-Jan-20 9:45
mveDave Kreskowiak15-Jan-20 9:45 
GeneralRe: OleDb Error [UPDATED] Pin
Kevin Marois15-Jan-20 10:51
professionalKevin Marois15-Jan-20 10:51 
GeneralRe: OleDb Error [UPDATED] Pin
Eddy Vluggen15-Jan-20 12:15
professionalEddy Vluggen15-Jan-20 12:15 
GeneralRe: OleDb Error [UPDATED] Pin
Dave Kreskowiak15-Jan-20 12:50
mveDave Kreskowiak15-Jan-20 12:50 
GeneralRe: OleDb Error [UPDATED] Pin
Eddy Vluggen15-Jan-20 12:57
professionalEddy Vluggen15-Jan-20 12:57 
QuestionException Handling Question Pin
Kevin Marois14-Jan-20 18:53
professionalKevin Marois14-Jan-20 18:53 
AnswerRe: Exception Handling Question Pin
OriginalGriff14-Jan-20 21:19
mveOriginalGriff14-Jan-20 21:19 
AnswerRe: Exception Handling Question Pin
F-ES Sitecore14-Jan-20 22:49
professionalF-ES Sitecore14-Jan-20 22:49 
SuggestionRe: Exception Handling Question Pin
Richard Deeming15-Jan-20 0:38
mveRichard Deeming15-Jan-20 0:38 
AnswerRe: Exception Handling Question Pin
Gerry Schmitz15-Jan-20 13:44
mveGerry Schmitz15-Jan-20 13:44 
QuestionHow to add text to a script tag at src using jQuery Pin
Member 1316600712-Jan-20 7:52
Member 1316600712-Jan-20 7:52 
AnswerRe: How to add text to a script tag at src using jQuery Pin
OriginalGriff12-Jan-20 10:25
mveOriginalGriff12-Jan-20 10:25 
Questioni need a c# project using interfaces about anything Pin
Ali Al Akbar Hachem12-Jan-20 4:23
Ali Al Akbar Hachem12-Jan-20 4: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.