Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. how to solve this error??

how to solve this error??

Scheduled Pinned Locked Moved ASP.NET
databasesysadminhelptutorialquestion
14 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dipan Patel From Gandhinagar
    wrote on last edited by
    #1

    error is : Timeout expired. The Timeout period elapsed prior to completion of the operation or the server is not responding.. This error comes when i used the datareader and passed the query . Dipan Patel.

    C 1 Reply Last reply
    0
    • D Dipan Patel From Gandhinagar

      error is : Timeout expired. The Timeout period elapsed prior to completion of the operation or the server is not responding.. This error comes when i used the datareader and passed the query . Dipan Patel.

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      Your query is taking longer than (by default) 30 seconds to run. If you expect your query to be completed in less than 30 seconds then there is a problem with your query. Otherwise you need to increase the CommandTimeout on the SqlCommand object to a satisfactory value.


      "On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog -- modified at 9:11 Saturday 6th May, 2006

      D 2 Replies Last reply
      0
      • C Colin Angus Mackay

        Your query is taking longer than (by default) 30 seconds to run. If you expect your query to be completed in less than 30 seconds then there is a problem with your query. Otherwise you need to increase the CommandTimeout on the SqlCommand object to a satisfactory value.


        "On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog -- modified at 9:11 Saturday 6th May, 2006

        D Offline
        D Offline
        Dipan Patel From Gandhinagar
        wrote on last edited by
        #3

        please write in more detail... Dipan Patel.

        C 1 Reply Last reply
        0
        • D Dipan Patel From Gandhinagar

          please write in more detail... Dipan Patel.

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          The detail I gave is commensurate with the detail you gave in the original question. There was enough information to use Google or MSN Search to find the entry in MSDN: SqlCommand.CommandTimeout[^] You should learn how to use search engines - they are are most useful invention.


          "On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog -- modified at 9:21 Saturday 6th May, 2006

          D 1 Reply Last reply
          0
          • C Colin Angus Mackay

            Your query is taking longer than (by default) 30 seconds to run. If you expect your query to be completed in less than 30 seconds then there is a problem with your query. Otherwise you need to increase the CommandTimeout on the SqlCommand object to a satisfactory value.


            "On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog -- modified at 9:11 Saturday 6th May, 2006

            D Offline
            D Offline
            Dipan Patel From Gandhinagar
            wrote on last edited by
            #5

            see Colin Angus Mackay, i wrote the code like --- dim Conn as New connect ' the file named connect.vb dim dr as sqldatareader dim query as string query="select * from enquiry" ' Error occur in below sentence dr=Conn.adpter(query) ' it call adpter(string) if dr.Read then end if --- The code written in adpter() Public Function adpter(ByVal pstr As String) As SqlDataReader dim s as sqlDataReader dim conn as new sqlconnection dim cmd as sqlcommand conn.open() cmd=New sqlcommand(pstr,conn) s=cmd.executereader() return s end function --- This function works properly 100% with other web forms.. but in this form i got the error... so help me.. Dipan Patel.

            C 1 Reply Last reply
            0
            • D Dipan Patel From Gandhinagar

              see Colin Angus Mackay, i wrote the code like --- dim Conn as New connect ' the file named connect.vb dim dr as sqldatareader dim query as string query="select * from enquiry" ' Error occur in below sentence dr=Conn.adpter(query) ' it call adpter(string) if dr.Read then end if --- The code written in adpter() Public Function adpter(ByVal pstr As String) As SqlDataReader dim s as sqlDataReader dim conn as new sqlconnection dim cmd as sqlcommand conn.open() cmd=New sqlcommand(pstr,conn) s=cmd.executereader() return s end function --- This function works properly 100% with other web forms.. but in this form i got the error... so help me.. Dipan Patel.

              C Offline
              C Offline
              Colin Angus Mackay
              wrote on last edited by
              #6

              dipanmaster4u wrote:

              This function works properly 100% with other web forms..

              Either this statement is false, or the code you posted is not the code you are using. The code you have posted cannot work as it would throw an exception about a lack of connection string.


              "On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog

              D 1 Reply Last reply
              0
              • C Colin Angus Mackay

                The detail I gave is commensurate with the detail you gave in the original question. There was enough information to use Google or MSN Search to find the entry in MSDN: SqlCommand.CommandTimeout[^] You should learn how to use search engines - they are are most useful invention.


                "On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog -- modified at 9:21 Saturday 6th May, 2006

                D Offline
                D Offline
                Dipan Patel From Gandhinagar
                wrote on last edited by
                #7

                I tried before it... if any other solution then tell me Dipan Patel.

                1 Reply Last reply
                0
                • C Colin Angus Mackay

                  dipanmaster4u wrote:

                  This function works properly 100% with other web forms..

                  Either this statement is false, or the code you posted is not the code you are using. The code you have posted cannot work as it would throw an exception about a lack of connection string.


                  "On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog

                  D Offline
                  D Offline
                  Dipan Patel From Gandhinagar
                  wrote on last edited by
                  #8

                  hello sir, i already this function in 20 webforms... and works successfully... but in one form it not worked.. so there is not way to say that this code is wrong... Dipan Patel.

                  C 1 Reply Last reply
                  0
                  • D Dipan Patel From Gandhinagar

                    hello sir, i already this function in 20 webforms... and works successfully... but in one form it not worked.. so there is not way to say that this code is wrong... Dipan Patel.

                    C Offline
                    C Offline
                    Colin Angus Mackay
                    wrote on last edited by
                    #9

                    dipanmaster4u wrote:

                    so there is not way to say that this code is wrong...

                    Then you did not post the actual code you are using because there is no connection string and without a connection string you cannot access any database. You need to post the actual code that you are using otherwise it does not help me to help you!


                    "On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog

                    D 1 Reply Last reply
                    0
                    • C Colin Angus Mackay

                      dipanmaster4u wrote:

                      so there is not way to say that this code is wrong...

                      Then you did not post the actual code you are using because there is no connection string and without a connection string you cannot access any database. You need to post the actual code that you are using otherwise it does not help me to help you!


                      "On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog

                      D Offline
                      D Offline
                      Dipan Patel From Gandhinagar
                      wrote on last edited by
                      #10

                      -- this is code for connect.vb Imports System.Data.SqlClient Public Class connect Dim str As String Dim conn As New SqlConnection Public ds As DataSet Dim cmd As SqlCommand Public Sub setconnection() str = ConfigurationSettings.AppSettings("connstr") conn.ConnectionString = str End Sub Public Function adpter(ByVal pstr As String) As SqlDataReader Dim s As SqlDataReader conn.Open() cmd = New SqlCommand(pstr, conn) 'cmd.CommandTimeout = 15 s = cmd.ExecuteReader() Return s End Function end class ----- In my "fees.aspx" form Imports System.Data.SqlClient Public Class RegularFees Inherits System.Web.UI.Page Dim Conn As New connect Private Sub SAVE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SAVE.Click Dim dr As SqlDataReader Dim query as String query = "Select * from ENQUIRY where enquiryformno=2" dr = Conn.adpter(query) If dr.Read Then txtPayment.text=dr(0) End If End Sub End class -------- so u better try it... Dipan Patel.

                      C 1 Reply Last reply
                      0
                      • D Dipan Patel From Gandhinagar

                        -- this is code for connect.vb Imports System.Data.SqlClient Public Class connect Dim str As String Dim conn As New SqlConnection Public ds As DataSet Dim cmd As SqlCommand Public Sub setconnection() str = ConfigurationSettings.AppSettings("connstr") conn.ConnectionString = str End Sub Public Function adpter(ByVal pstr As String) As SqlDataReader Dim s As SqlDataReader conn.Open() cmd = New SqlCommand(pstr, conn) 'cmd.CommandTimeout = 15 s = cmd.ExecuteReader() Return s End Function end class ----- In my "fees.aspx" form Imports System.Data.SqlClient Public Class RegularFees Inherits System.Web.UI.Page Dim Conn As New connect Private Sub SAVE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SAVE.Click Dim dr As SqlDataReader Dim query as String query = "Select * from ENQUIRY where enquiryformno=2" dr = Conn.adpter(query) If dr.Read Then txtPayment.text=dr(0) End If End Sub End class -------- so u better try it... Dipan Patel.

                        C Offline
                        C Offline
                        Colin Angus Mackay
                        wrote on last edited by
                        #11

                        A number of possibilities. 1. The table is large and it takes the SQL Server a long time to filter on enquiryformno. Indexing that column might help speed things up. 2. You don't seem to close the SqlDataReader. It is possible that the SQL Server has locks on objects and it is waiting for those locks to be released. So, once you've used your Data Reader remember to Close it. 3. You SELECT * yet only get the first column of the first row. You would be better using SELECT justOneColumnName with ExecuteScalar rather than use a SqlDataReader. This would automatically solve 2 also.


                        "On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog

                        D 1 Reply Last reply
                        0
                        • C Colin Angus Mackay

                          A number of possibilities. 1. The table is large and it takes the SQL Server a long time to filter on enquiryformno. Indexing that column might help speed things up. 2. You don't seem to close the SqlDataReader. It is possible that the SQL Server has locks on objects and it is waiting for those locks to be released. So, once you've used your Data Reader remember to Close it. 3. You SELECT * yet only get the first column of the first row. You would be better using SELECT justOneColumnName with ExecuteScalar rather than use a SqlDataReader. This would automatically solve 2 also.


                          "On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog

                          D Offline
                          D Offline
                          Dipan Patel From Gandhinagar
                          wrote on last edited by
                          #12

                          sir i write the conn.close() in " if dr.read then ...after the dr(0). so not worry about the connection close.. and writing the executescalar in this.. it also gives the same error... i take also only one column name.... Dipan Patel.

                          C I 2 Replies Last reply
                          0
                          • D Dipan Patel From Gandhinagar

                            sir i write the conn.close() in " if dr.read then ...after the dr(0). so not worry about the connection close.. and writing the executescalar in this.. it also gives the same error... i take also only one column name.... Dipan Patel.

                            C Offline
                            C Offline
                            Colin Angus Mackay
                            wrote on last edited by
                            #13

                            I don't see where the connection or Data Reader are being closed.


                            "On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog

                            1 Reply Last reply
                            0
                            • D Dipan Patel From Gandhinagar

                              sir i write the conn.close() in " if dr.read then ...after the dr(0). so not worry about the connection close.. and writing the executescalar in this.. it also gives the same error... i take also only one column name.... Dipan Patel.

                              I Offline
                              I Offline
                              Ista
                              wrote on last edited by
                              #14

                              To add. If you dont call dispose on the connection object, It will not pool the connection and will eventually cause timeouts. Thats because they are never really sent back to the pool without calling dispose. 1 line of code equals many bugs. So don't write any!!

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • World
                              • Users
                              • Groups