Your reposted question shows a little more info - don't do that, edit your existing question using the Improve Question to provide better info - and it's possible that that shows what the problem is.
try
{
con.Open();
string qry = "select * from ShopOwnMast where EmailId='" + Session["emailid"].ToString() + "'";
SqlDataAdapter adp = new SqlDataAdapter(qry, con);
DataTable dt = new DataTable();
adp.Fill(dt);
Session["ShopId"] = dt.Rows[0][8].ToString();
string shopid = Session["ShopId"].ToString();
string qry1 = "Select * from ShopMast where shopid ='" + shopid + "'";
SqlDataAdapter adp1 = new SqlDataAdapter(qry1, con);
DataTable dt1 = new DataTable();
adp1.Fill(dt1);
lblShopName.Text = dt1.Rows[0][1].ToString();
getdata();
}
catch (Exception ex)
{
System.Console.WriteLine(ex);
}
finally
{
con.Close();
}
Couple of things to check:
First off, don't use SELECT * FROM if you are only going to use one row and one column - it's very inefficient. Instead use
SELECT TOP 1 MYColumnName FROM
The
TOP 1
part restricts it to one row (which is what you would hopefully get anyway).
The named column means you don't fetch information you aren't going to use.
The second thing that worries me is that when you have used the one data item, you call a method called
getdata
- and I'm wondering if that method is the one you are in. I.e.
private void getdata()
{
try
{
con.Open();
string qry = "select * from ShopOwnMast where EmailId='" + Session["emailid"].ToString() + "'";
SqlDataAdapter adp = new SqlDataAdapter(qry, con);
DataTable dt = new DataTable();
adp.Fill(dt);
Session["ShopId"] = dt.Rows[0][8].ToString();
string shopid = Session["ShopId"].ToString();
string qry1 = "Select * from ShopMast where shopid ='" + shopid + "'";
SqlDataAdapter adp1 = new SqlDataAdapter(qry1, con);
DataTable dt1 = new DataTable();
adp1.Fill(dt1);
lblShopName.Text = dt1.Rows[0][1].ToString();
getdata();
}
catch (Exception ex)
{
System.Console.WriteLine(ex);
}
finally
{
con.Close();
}
}
If so, then your code will recursively call itself, and that will use the entire SQL connection pool very, very quickly - which is one of the things that could easily cause the effect you have.
And as Richard has said: Do not concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead.