Re: System.Data.SqlClient.SqlException: Timeout expired. The timeout p

Discussion in 'ASP .Net' started by Karl Seguin, Apr 14, 2005.

  1. Karl Seguin

    Karl Seguin Guest

    If you are running a long query, you'll need to set a higher timeout for the
    sqlcommand....it defaults to 20 or 30 or something seconds....

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
    http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
    come!)


    "Deepak" <> wrote in message
    news:...
    > When i am using the Sqlserver with Asp.net i am getting this problem:
    >
    > System.Data.SqlClient.SqlException: Timeout expired. The timeout period
    > elapsed prior to completion of the operation or the server is not

    responding.
    > at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
    > cmdBehavior, RunBehavior runBehavior, Boolean returnStream) at
    > System.Data.SqlClient.SqlCommand.ExecuteScalar() at
    Karl Seguin, Apr 14, 2005
    #1
    1. Advertising

  2. Karl Seguin

    Arun M

    Joined:
    Sep 4, 2007
    Messages:
    1
    Hi

    The following code will connect the sql adapter and sql command, applying this will solve the timeout exception

    DbConn.Open()
    Dim DbCmd As New SqlClient.SqlDataAdapter
    Dim cmd As New SqlCommand(sSQL, DbConn)
    cmd.CommandTimeout = 250
    DbCmd.SelectCommand = cmd
    Dim Dt As New DataTable
    DbCmd.Fill(Dt)
    DbConn.Close()
    Return Dt

    Same logic can be applied to oledb command also

    Dim DbCmd As New OleDb.OleDbDataAdapter
    Dim cmd As New OleDb.OleDbCommand(sSQL, OraConn)
    cmd.CommandTimeout = 250
    DbCmd.SelectCommand = cmd
    Dim Dt As New DataTable
    DbCmd.Fill(Dt)
    DbConn.Close()
    Return Dt

    Happy Programming
    Arun M, Sep 4, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hb
    Replies:
    3
    Views:
    5,009
  2. =?Utf-8?B?TWF0dA==?=

    SqlClient.SqlException: Timeout expired.

    =?Utf-8?B?TWF0dA==?=, Mar 28, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    6,882
    =?Utf-8?B?TWF0dA==?=
    Mar 29, 2005
  3. Karl Seguin
    Replies:
    0
    Views:
    593
    Karl Seguin
    Apr 14, 2005
  4. Ersin Gençtürk
    Replies:
    1
    Views:
    7,208
    jmohanty2006
    Sep 25, 2007
  5. egsdar
    Replies:
    0
    Views:
    1,555
    egsdar
    Dec 13, 2008
Loading...

Share This Page