Pnkl

Pnkl

  • NA
  • 114
  • 66k

Data Lost on Multiple Request in Asp.Net Web site

Dec 9 2015 5:59 AM
Hello Guys,
 
I have Developed one website in Asp.Net 4.0 And Sql Server 2012 And I used 3-tier Data Access method but sometimes many requests are occur then data lost from Sql Server Db so why this happen?
 
If you have solution then reply me.
 
Below is my sample code 
in  DataClass.cs filldata method :
public static SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString); 
public static DataTable Filladptor(SqlCommand cmd)
{
DataTable dt = new DataTable();
cmd.Connection = cn;
SqlDataAdapter adp = new SqlDataAdapter(cmd);
try
{
//cmd = new SqlCommand();
if (cn.State == ConnectionState.Closed)
{
cn.Open();
}
adp.Fill(dt);
}
catch (Exception ex)
{
errmsg = ex.Message;
}
finally
{
cmd.Dispose();
if (cn.State == ConnectionState.Open)
{
cn.Close();
}
}
return dt;
}
 
IN Webconfig Connectionstring:
 
<add name="constr" connectionString="Data Source=MyServerIp;User ID=myusername;Password=mypassword;persist security info=False;Initial catalog=myDB;Connection Timeout=15;Connection Lifetime=0;Min Pool Size=0;Max Pool Size=100;Pooling=true;" providerName="System.Data.SqlClient"/> 
 
Thanks.. 
 

Answers (4)