Solved

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

Posted on 2014-02-10
3
269 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

895 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