Solved

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

Posted on 2014-02-10
3
267 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
Comment Utility
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 19

Accepted Solution

by:
Daniel Van Der Werken earned 500 total points
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Familiarize people with the process of utilizing SQL Server functions 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 Microsoft Ac…
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…

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now