Solved

Too many client tasks Error in asp.net with C#

Posted on 2014-02-10
3
272 Views
Last Modified: 2014-02-17
Hello Experts,

We developed one site with MS Access database and use DSN based connection. here my problem is the site give me error "Too many client tasks". i restart my server and it's solved but after sometimes it's again come. can you please suggest how can i resolve it.

Here i put my code.
 
using (OdbcConnection con = new OdbcConnection(conString))
            {
                con.Open();
                using (OdbcCommand cmd = new OdbcCommand(cmdText, con))
                {
                    cmd.CommandType = cmdType;
                    if (parameters != null)
                    {
                        foreach (OdbcParameter parameter in parameters)
                        {
                            if (null != parameter) cmd.Parameters.Add(parameter);
                        }
                    }
                    using (OdbcDataAdapter da = new OdbcDataAdapter(cmd))
                    {
                        DataSet ds = new DataSet();
                        da.Fill(ds);
                        return ds;
                    }
                }
            }

Open in new window

0
Comment
Question by:dotsandcoms
3 Comments
 
LVL 11

Expert Comment

by:John_Vidmar
ID: 39847233
You've instantiated an ODBCConnection object and opened a connection to the data-source... do you ever explicitly close the connection? (the code-snipet you provided does not close the connection).
0
 
LVL 20

Accepted Solution

by:
Daniel Van Der Werken earned 500 total points
ID: 39848428
The using statement auto-closes. What I think is happening is you are calling return within the using, thereby ending execution prior to the full close. Try this:
DataSet ds = new DataSet();
using (OdbcConnection con = new OdbcConnection(conString))
{
	con.Open();
	using (OdbcCommand cmd = new OdbcCommand(cmdText, con))
	{
		cmd.CommandType = cmdType;
		if (parameters != null)
		{
			foreach (OdbcParameter parameter in parameters)
			{
				if (null != parameter) cmd.Parameters.Add(parameter);
			}
		}
		using (OdbcDataAdapter da = new OdbcDataAdapter(cmd))
		{
			da.Fill(ds);
		}
	}
}
return ds;

Open in new window

0
 

Author Comment

by:dotsandcoms
ID: 39852732
Hello Dan7el,

I have updated the code as per your comments but still same error come. this error come in all sites which is hosted on the same server. so is there any settings in odbc connection to resolve it?
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question