Where should I keep connection object to database like ISession or SQLConnection?
What's the best solution and why ? Is it Application, Session or Items ?

for creating the session "global.asax" file is right,
when you creating the session u must wright the code "Session["sec"] = 0" inside the Session_Start () function.
and for connection the web.config is right for connection string code is

<connectionStrings>
      <remove name="conn"/>
      <add name="conn" connectionString="Data Source=.;Initial Catalog=addbook;Integrated Security=True" providerName="System.Data.SqlClient"/>
    
  </connectionStrings>

Okay, thanks. But If I could only choose one of three objects (Application, Session or Items) then which one would be the best solution ?

Its not good practice to store connection in Memory for ASP.NET.
Make data layer which will connect to DB.
best practice keep Connection Pool so connection are not reopened all time(if frequent visit of database/multiple user)
Check http://www.15seconds.com/issue/040830.htm

ok, thanks

I have never seen the "remove" code in the connection strings area. What is this needed for?

for creating the session "global.asax" file is right,
when you creating the session u must wright the code "Session["sec"] = 0" inside the Session_Start () function.
and for connection the web.config is right for connection string code is

<connectionStrings>
      <remove name="conn"/>
      <add name="conn" connectionString="Data Source=.;Initial Catalog=addbook;Integrated Security=True" providerName="System.Data.SqlClient"/>
    
  </connectionStrings>

http://infynet.wordpress.com

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.