Results 1 to 4 of 4

Thread: [2005] Shared objects VS Local objects

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2006
    Location
    Surabaya, Indonesia
    Posts
    163

    [2005] Shared objects VS Local objects

    I have these variable:
    vb Code:
    1. Public Shared SQLConn As SqlClient.SqlConnection

    It use for doing ADO.NET connection. So, after I finished database processing, I close and re-use that variable. Is it wise? Which are better than I use this on every ADO.NET transaction?
    vb Code:
    1. Using MyConn As New SqlClient.SqlConnection
    2.     'DB processing here
    3. End Using

    Since I heard that Garbage Collector won't remove an object immediately, I thought an idea about using a single object repeatedly than create and dispose an object each processing.

    Regards,

    Michael
    Last edited by michaelrawi; Dec 7th, 2007 at 04:37 AM. Reason: Add the VB code tag
    Check my Blog at VB Corner,Component Crafts

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width