Click here to Skip to main content
15,921,062 members
Home / Discussions / C#
   

C#

 
GeneralRe: Clear comments and rename var/method names at compile time Pin
Lupu5R3x18-Jan-20 6:57
Lupu5R3x18-Jan-20 6:57 
GeneralRe: Clear comments and rename var/method names at compile time Pin
OriginalGriff18-Jan-20 7:01
mveOriginalGriff18-Jan-20 7:01 
AnswerRe: Clear comments and rename var/method names at compile time Pin
Gerry Schmitz18-Jan-20 7:00
mveGerry Schmitz18-Jan-20 7:00 
GeneralRe: Clear comments and rename var/method names at compile time Pin
Lupu5R3x18-Jan-20 7:09
Lupu5R3x18-Jan-20 7:09 
GeneralRe: Clear comments and rename var/method names at compile time Pin
Dave Kreskowiak18-Jan-20 16:03
mveDave Kreskowiak18-Jan-20 16:03 
GeneralRe: Clear comments and rename var/method names at compile time Pin
Gerry Schmitz18-Jan-20 17:30
mveGerry Schmitz18-Jan-20 17:30 
Questioncompare two dictionary and display difference Pin
mjbaquiran18-Jan-20 0:01
mjbaquiran18-Jan-20 0:01 
QuestionRe: compare two dictionay and display difference Pin
Eddy Vluggen18-Jan-20 0:30
professionalEddy Vluggen18-Jan-20 0:30 
AnswerRe: compare two dictionay and display difference Pin
mjbaquiran18-Jan-20 7:05
mjbaquiran18-Jan-20 7:05 
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 

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.