How to improve asp.net sql connection performance?

  • Thread starter Thread starter bornleader
  • Start date Start date
B

bornleader

Guest
Hi
I am developing a Portal Application in asp.net and sql 2005 . And each page load i need atleast 3000 DB Records to b fetched and displayed,
Here i created a Class named Connection [for DB connectivity ] and Query Class [ getting/setting db queries ]
.Each time fetching query class calls Connection class and fetches the record and returns.

So in my appln, 3000 times(atleast) DB connection creates and closes .
Is der any method to solve this problem of so many db connection (opening and closing)?

This is Query class

// select (row1 +'/' + row2) as row from table;
public static ArrayList getQueryResults(string query)
{
try
{
cmd.Connection = Connection.getConnection();
cmd.CommandText = query;
rs = cmd.ExecuteReader();
al_temp = new ArrayList();
if (rs.HasRows)
{

while (rs.Read())
{
al_temp.Add(rs[0]);
}
}
}
catch (Exception) { }
finally
{

rs.Close();
cmd.Cancel();
cmd.Connection.Close();
Connection.closeConnection();

}
return al_temp;
}

Connection class

public static System.Data.SqlClient.SqlConnection getConnection()
{
try
{
string cs=DecryptConnectionString("RGF0YSBTb3"+ConfigurationManager.ConnectionStrings["sitemaster"].ToString() + "MGI2NDY=");
try
{
//if (sqlCon.State == ConnectionState.Open) return sqlCon;
}
catch (Exception) { }
sqlCon = new System.Data.SqlClient.SqlConnection(cs);
sqlCon.Open();

}
catch (Exception) { }
return sqlCon;
}

public static void closeConnection()
{
try
{
sqlCon.Close();
}
catch (Exception) { }

}


Please help me to improve my applications Performance
 
Back
Top