1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

DB Connection with Application/Page Scope

Discussion in 'C#' started by Hazzardusa, Aug 15, 2005.

  1. #1
    if a website is getting 100+ DB connection and recordset calls a minute, would it be better to set up 1 application level database connection strings and about 10 application level recordset objects that would handle 90% of the traffic? or would it be better to just open the database everytime i need it.
    SEMrush
     
    Hazzardusa, Aug 15, 2005 IP
    SEMrush
  2. mopacfan

    mopacfan Peon

    Messages:
    3,273
    Likes Received:
    164
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I would think that having appllication level connections could get confused between which pages are calling them. I would recommend opening and closing the connection on each page. I've run some pretty high traffic sites and never had a problem with the database connections being set up on each page.
     
    mopacfan, Aug 15, 2005 IP
  3. Hazzardusa

    Hazzardusa Guest

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    if i only had one connection string used in the whole website and there were 10 or so recordsets being called every few seconds.

    i am already going to set up the recordsets as application veriables because they are the same for everyone no matter when you call them

    i am still trying to figure out how to set up a connection or a recordset inside the application onstart section of the global.asa file
    i read that you are supposed to use the object tag but i can never find an example of it in the asa file and this doesn't work

    Sub Application_OnStart
    <object id="connection" runat="server" progid="ADODB.Connection">
    </object>
    End Sub

    and neither does this

    Sub Application_OnStart
    Set Application("cn ")= Server.CreateObject("ADODB.Connection")
    Application("cn").Open Application("Data_Server")
    End Sub

    any ideas?
     
    Hazzardusa, Aug 15, 2005 IP
  4. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    64
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Unless you have very specific requirements and you know what you are doing, it's a bad idea to implement your own connection pooling. Windows supports connection pooling on the driver level (ODBC or OLEDB) and you just need to make sure it's turned on on your system. Here's more info:

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnmdac/html/pooling2.asp

    J.D.
     
    J.D., Aug 15, 2005 IP
  5. heyman

    heyman Peon

    Messages:
    70
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    make sure you use the latest OleDb providers. If you are not using ASP.NET - then I will recommend you use it. Within ASP.NET use SqlClient to connect to your Sql database. It is very scalable and handles connection pooling very nicely
     
    heyman, Aug 25, 2005 IP