none
Unified Data Access using Microsoft Enterprise Data access application block or ADO.DotNet RRS feed

  • Question

  • I want to write a generic Data logger application.

    The application provides option to log data in Sql Server ,Oracle or Ms Access.

    Is it possible to use different connection strings and same data access code ( to do the inserts in the table)?

    Does Data access application block support Oracle and Ms Access?

    Also since my application is continiously logging I want to keep the connection open till the user clicks stop logging button.

    Is it possible with data access application block?


    Rajesh S Harwani

    Friday, March 13, 2015 8:47 AM

Answers

  • Hello Rajesh,

    For issues about Microsoft Enterprise Data access api, it is beyond the scope of this forum, you could ask question about this api to the Microsoft Enterprise forum:

    https://entlib.codeplex.com/workitem/list/basic

    >> Is it possible to use different connection strings and same data access code ( to do the inserts in the table)?

    With ADO.NET, it is possible to use different connecting string and same data access code. You could use the OleDB provider which uses native OLE DB through COM interop to enable data access, you could use it as below,

    string connectionString = "";
    
                    string sqlStatement = "";
    
                    OleDbConnection conn = new OleDbConnection(connectionString);//@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Sample20150122.xlsx;Extended Properties='Excel 12.0 XML;HDR=Yes;'"
    
                    try
    
                    {
    
                        conn.Open();
    
                        OleDbCommand cmd = new OleDbCommand(sqlStatement, conn);
    
                        OleDbDataAdapter da = new OleDbDataAdapter(cmd);
    
                        System.Data.DataSet ds = new System.Data.DataSet();
    
                        da.Fill(ds);
    
                    }
    
                    catch (Exception)
    
                    {
    
                    }
    
                    finally
    
                    {
    
                        conn.Close();
    
                    } 
    

    However, if for SQL Server, it is recommended to use SqlClient as the .NET Provider which proivdes a better performance.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, March 16, 2015 3:16 AM
    Moderator