Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Should I close the connection?

tijoentijoen Member Posts: 141
Hi,

I am developing a website(a big portal) and it is dedicated to my project

should I close the connection with the database?
because I am the only one connecting to it and i will only use one connection..
Is it going to be good or won't matter?
less memory and processing usage?

using Sql Server, asp.net c#

thank you!

Joe

Comments

  • HackmanCHackmanC Member Posts: 441
    [color=Purple]If you are the only one connected to SQL Server, it doesnt matter.
    [b]You will get better performance for your application opening a connection each time a user connects and closing after.[/b]

    But ... [color=Green]developing a website(a big portal)[/color] ... you will get a lot of visitors? Or only you are going to browse your big portal? [size=2](Developer machine, Demo, Homework)[/size]

    The meaning of [color=Green]"you are the only connected to the database"[/color] brokes if you get a lot of visitors. If you had a component who reads the database, is used on 1 ASP, but 1000 people will watch that page (at intervals), will broke the whole concept of "you are the only one".[/color]

    [hr]

    : Hi,
    :
    : I am developing a website(a big portal) and it is dedicated to my
    : project
    :
    : should I close the connection with the database?
    : because I am the only one connecting to it and i will only use one
    : connection..
    : Is it going to be good or won't matter?
    : less memory and processing usage?
    :
    : using Sql Server, asp.net c#
    :
    : thank you!
    :
    : Joe

    [red]Good luck![/red]
    [blue]Hackman[/blue]
  • tijoentijoen Member Posts: 141
    Yes, there will be lots of users connected to the website
    and now, i received an info from my boss that we are going to use a semi-dedicated server, so, there will be others connected to the same sqlserver
    then the question:
    will it make difference(good or not) if I do not close the connection to the database?

    thanks for your answer,
    Joe

    : [color=Purple]If you are the only one connected to SQL Server, it
    : doesnt matter.
    : [b]You will get better performance for your application opening a
    : connection each time a user connects and closing after.[/b]
    :
    : But ... [color=Green]developing a website(a big portal)[/color] ...
    : you will get a lot of visitors? Or only you are going to browse your
    : big portal? [size=2](Developer machine, Demo, Homework)[/size]
    :
    : The meaning of [color=Green]"you are the only connected to the
    : database"[/color] brokes if you get a lot of visitors. If you had a
    : component who reads the database, is used on 1 ASP, but 1000 people
    : will watch that page (at intervals), will broke the whole concept of
    : "you are the only one".[/color]
    :
    : [hr]
    :
    : : Hi,
    : :
    : : I am developing a website(a big portal) and it is dedicated to my
    : : project
    : :
    : : should I close the connection with the database?
    : : because I am the only one connecting to it and i will only use one
    : : connection..
    : : Is it going to be good or won't matter?
    : : less memory and processing usage?
    : :
    : : using Sql Server, asp.net c#
    : :
    : : thank you!
    : :
    : : Joe
    :
    : [red]Good luck![/red]
    : [blue]Hackman[/blue]
  • HackmanCHackmanC Member Posts: 441

    [color=Purple]It will make a huge difference [color=Red](bad)[/color] if you dont close the connection to the database. This is from my own experience, if the whole conection [size=2](pid deadlock)[/size] deadlock then your whole application deadlock. :o[/color]

    [color=Purple]If you open and close the connections, whatever happens on one conection doesnt matter, because you will use another one, with the next customer. The deadlock connections will be released by SQL Server some time later.[/color]

    [color=Purple]You will need more memory and processing usage? yes, just a bit! ADO.NET like ADO mantains an internal conection pool, you cant control the pool, (I havent read it, so I cant tell you Microsoft said ... "there is a connection pool", but if you see the guts of an application -dissasemble, etc.- you see something like a pool there!), the first time you connect, it takes some time, next connection is farely quick and use a previous slot? space? resource? you know.[/color]

    [size=1][color=Green]Background:
    I developed huge web applications to access huge information in my country, with the formula : open/close. When the corporation I work with send me to develop in other country, them already has some coding with one open and one close. Until we change that ... we did get the quality of service them was expecting. (The kind of ... we had here).[/color][/size]
    [red]Good luck![/red]
    [blue]Hackman[/blue]
  • tijoentijoen Member Posts: 141
    first: thanks for your answer!

    do you have any link about this?
    because some dudes here don't believe...

    thanks a lot!
    Joe
    :
    : [color=Purple]It will make a huge difference
    : [color=Red](bad)[/color] if you dont close the connection to the
    : database. This is from my own experience, if the whole conection
    : [size=2](pid deadlock)[/size] deadlock then your whole application
    : deadlock. :o[/color]
    :
    : [color=Purple]If you open and close the connections, whatever
    : happens on one conection doesnt matter, because you will use another
    : one, with the next customer. The deadlock connections will be
    : released by SQL Server some time later.[/color]
    :
    : [color=Purple]You will need more memory and processing usage? yes,
    : just a bit! ADO.NET like ADO mantains an internal conection pool,
    : you cant control the pool, (I havent read it, so I cant tell you
    : Microsoft said ... "there is a connection pool", but if you see the
    : guts of an application -dissasemble, etc.- you see something like a
    : pool there!), the first time you connect, it takes some time, next
    : connection is farely quick and use a previous slot? space? resource?
    : you know.[/color]
    :
    : [size=1][color=Green]Background:
    : I developed huge web applications to access huge information in my
    : country, with the formula : open/close. When the corporation I work
    : with send me to develop in other country, them already has some
    : coding with one open and one close. Until we change that ... we did
    : get the quality of service them was expecting. (The kind of ... we
    : had here).[/color][/size]
    : [red]Good luck![/red]
    : [blue]Hackman[/blue]
  • HackmanCHackmanC Member Posts: 441
    [color=Purple]I cant link to any of the sites I had develop. Those arent public.
    Even if post the link you will need a password.[/color]
    [hr]
    Even when is not Microsoft SQL Server, this concept is related :
    [link=http://www.ibm.com/developerworks/db2/library/techarticle/dm-0404theivendran/index.html]IBM Library[/link]

    Pooling and Best Practices:
    [link=http://www.wintellect.com/Articles/ADO NET Connection.pdf]Wintellect[/link]
    [link=http://en.wikipedia.org/wiki/Connection_Pool]Wiki[/link]
    [link=http://msdn2.microsoft.com/en-us/library/ms978510.aspx]Microsoft MSDN[/link]

    [red]Good luck![/red]
    [blue]Hackman[/blue]
Sign In or Register to comment.