DataSet TimeOut expires

Posted on 2005-04-27
Last Modified: 2008-01-09

The connection expires during   myAdapter.Fill(myDataSet, "TestTable")

        myAdapter = New SqlDataAdapter(sqlString, myConn)
        myDataSet = New DataSet
        myAdapter.Fill(myDataSet, "TestTable")

I have seen lot of examples on the net for  myCmd.CommandTimeout = 300, but that works only with sqlReader not with DataSet.

 How Can I fix timeout error? I know my query works. It takes close to 1 minute to run on sql server. Meanwhile asp application is throwing an error.
Question by:AnuPutcha
    LVL 6

    Expert Comment

    It won't answer your question, but if a query is taking a full minute to run on sql server it's probably too much data to return at one time to a webpage. I would look at optimizing the query before increasing the server time out.

    LVL 33

    Expert Comment

    You can also set the script timeout, this will probably fix your problem, but like Havagan said, 1 minute for a web-page result is pretty hefty.

    Server.ScriptTimeout = 300
    LVL 75

    Expert Comment

    by:Anthony Perkins

    >>You can also set the script timeout, this will probably fix your problem<<
    This is unrelated to ADO.NET and will have no effect.  The default timeout is 30 seconds for the CommandTimeout property.

    >>but that works only with sqlReader not with DataSet.<<
    There is nothing stopping you using the SqlCommand object when you instantiate the SqlDataAdapter
    LVL 33

    Expert Comment

    true, you have to really combine the commandtimeout and's commandtimeout for it to work properly.
    LVL 23

    Accepted Solution

    myAdapter = New SqlDataAdapter(sqlString, myConn)
    myDataSet = New DataSet
    'to set the timeout for the command
    myAdapter.SelectCommand.CommandTimeout = 300
    myAdapter.Fill(myDataSet, "TestTable")

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    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

    This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    759 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