?
Solved

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

Posted on 2014-02-10
3
Medium Priority
?
281 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 1000 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
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…
Suggested Courses

800 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