Click here to Skip to main content
15,888,283 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?

Suppose Many Users Acces Website From Many Locations at time and continue accessing (30 minute or 60 minute) then sometimes data lost or connection lost from server so you have solution for that then help me to resolve it

If you have solution then reply me.

Below is my sample code
in DataClass.cs filldata method :
C#
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:

XML
<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..
Posted
Updated 14-Dec-15 22:37pm
v2
Comments
Suvendu Shekhar Giri 15-Dec-15 0:47am    
Can you clarify what do you mean by "data lost" or "connection lost"?
Is it throwing some error/exception?
More details required.
JamesGill 15-Dec-15 1:19am    
connection lost that mean data not display at user side so, you have solution in this then help me. Also I put my sample code thats ok? OR any changes required then suggest me.

Thanks..
F-ES Sitecore 15-Dec-15 4:43am    
You're catching exceptions but doing nothing with them so you're not going to know if there is an error, or what that error is. Change your exception handler to show the error raised, or at least log it somewhere for you to review.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900