Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. The fastest Normal ADO.NET or Microsoft Best Practise EnterpriseLibrary

The fastest Normal ADO.NET or Microsoft Best Practise EnterpriseLibrary

Scheduled Pinned Locked Moved Database
csharpcomquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Albert Pascual
    wrote on last edited by
    #1

    So I got 2 classes one I wrote to interrogate databases using normal ADO: Mine: SqlConnection myConnection = new SqlConnection(m_sConnectionString); SqlCommand myCommand = new SqlCommand(sQuery, myConnection); myCommand.CommandTimeout = 120; // 60 Seconds Timeout myConnection.Open(); SqlDataReader result = myCommand.ExecuteReader(CommandBehavior.CloseConnection); return result; Microsoft Way SqlDatabase dbSvc = new SqlDatabase(m_sConnectionString); DbCommand dbCommand = dbSvc.GetSqlStringCommand(sQuery); return ((SqlDataReader)dbSvc.ExecuteReader(dbCommand)); What's faster? My way: SqlConnection myConnection = new SqlConnection(m_sConnectionString); SqlCommand myCommand = new SqlCommand(sQuery, myConnection); myCommand.CommandTimeout = 120; // 60 Seconds Timeout // Use a DataTable – required for default paging SqlDataAdapter myAdapter = new SqlDataAdapter(myCommand); DataTable myTable = new DataTable(); myAdapter.Fill(myTable); myConnection.Close(); myConnection.Dispose(); myConnection = null; return (myTable); Microsoft Way: SqlDatabase dbSvc = new SqlDatabase(m_sConnectionString); DbCommand dbCommand = dbSvc.GetSqlStringCommand(sQuery); DataTable dtData = null; DataSet dsData = dbSvc.ExecuteDataSet(dbCommand); dtData = dsData.Tables[0]; return (dtData); Comments? Ideas? Al My eMail control My Blog

    A 1 Reply Last reply
    0
    • A Albert Pascual

      So I got 2 classes one I wrote to interrogate databases using normal ADO: Mine: SqlConnection myConnection = new SqlConnection(m_sConnectionString); SqlCommand myCommand = new SqlCommand(sQuery, myConnection); myCommand.CommandTimeout = 120; // 60 Seconds Timeout myConnection.Open(); SqlDataReader result = myCommand.ExecuteReader(CommandBehavior.CloseConnection); return result; Microsoft Way SqlDatabase dbSvc = new SqlDatabase(m_sConnectionString); DbCommand dbCommand = dbSvc.GetSqlStringCommand(sQuery); return ((SqlDataReader)dbSvc.ExecuteReader(dbCommand)); What's faster? My way: SqlConnection myConnection = new SqlConnection(m_sConnectionString); SqlCommand myCommand = new SqlCommand(sQuery, myConnection); myCommand.CommandTimeout = 120; // 60 Seconds Timeout // Use a DataTable – required for default paging SqlDataAdapter myAdapter = new SqlDataAdapter(myCommand); DataTable myTable = new DataTable(); myAdapter.Fill(myTable); myConnection.Close(); myConnection.Dispose(); myConnection = null; return (myTable); Microsoft Way: SqlDatabase dbSvc = new SqlDatabase(m_sConnectionString); DbCommand dbCommand = dbSvc.GetSqlStringCommand(sQuery); DataTable dtData = null; DataSet dsData = dbSvc.ExecuteDataSet(dbCommand); dtData = dsData.Tables[0]; return (dtData); Comments? Ideas? Al My eMail control My Blog

      A Offline
      A Offline
      Albert Pascual
      wrote on last edited by
      #2

      Well, I run the test using an abstract class, and after a while I cannot tell you if mine or MS is slower. I may back to the drawing board to build a new one to use. This are my results: http://alpascual.com/blog/al/archive/2006/05/12/176.aspx[^] Cheers Al My eMail control My Blog

      R 1 Reply Last reply
      0
      • A Albert Pascual

        Well, I run the test using an abstract class, and after a while I cannot tell you if mine or MS is slower. I may back to the drawing board to build a new one to use. This are my results: http://alpascual.com/blog/al/archive/2006/05/12/176.aspx[^] Cheers Al My eMail control My Blog

        R Offline
        R Offline
        Rob Graham
        wrote on last edited by
        #3

        When doing performance tests it is often very difficult to see small difierences on a single operation. I usually try several hundred iterations (accumulating the timing results with each iteration using a high precision timer class that calls QueryPerformanceCounter) and look at the average performance. This smoothes out minor jitter caused by the OS doing stuff, and usually gives a better measure, especially when the individual operation times are small. We need to graduate from the ridiculous notion that greed is some kind of elixir for capitalism - it's the downfall of capitalism. Self-interest, maybe, but self-interest run amok does not serve anyone. The core value of conscious capitalism is enlightened self-interest. Patricia Aburdene

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups