Quantcast
Channel: CodeProject Latest postings for ASP.NET
Viewing all articles
Browse latest Browse all 3938

Query timing out, help please!!!

$
0
0
Greetings experts,

When I run my app with the following code:

Private Sub SearchCustomers()
      Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
      Dim startDate As DateTime
      Dim EndDate As DateTime
      Using con As New SqlConnection(constr)

          Using cmd As New SqlCommand()

              Dim sql As String = "spGetLogs"
              cmd.CommandType = CommandType.StoredProcedure
              cmd.Parameters.AddWithValue("@uuid", suuid.Text)
              cmd.Parameters.AddWithValue("@callerlist", caller_list_id.Text)
              cmd.Parameters.AddWithValue("@phone", phonenumber.Text)
              If DateTime.TryParseExact(date_start.Text, "yyyy-MM-dd HH:mm:ss", Nothing, System.Globalization.DateTimeStyles.None, startDate) Then
                  cmd.Parameters.AddWithValue("@start", startDate)
              Else
                  cmd.Parameters.AddWithValue("@start", DBNull.Value)
              End If
              If DateTime.TryParseExact(date_end.Text, "yyyy-MM-dd HH:mm:ss", Nothing, System.Globalization.DateTimeStyles.None, EndDate) Then
                  cmd.Parameters.AddWithValue("@Endd", EndDate)
              Else
                  cmd.Parameters.AddWithValue("@Endd", DBNull.Value)
              End If
              cmd.Parameters.AddWithValue("@calltype", call_type.SelectedValue)
              'Response.Write(sql)
              'Response.End()
              cmd.CommandText = sql
              cmd.CommandTimeout = 600
              cmd.Connection = con
              Using sda As New SqlDataAdapter(cmd)
                  Dim dt As New DataTable()
                  sda.Fill(dt)
                  gvCustomers.DataSource = dt
                  gvCustomers.DataBind()

              End Using
          End Using
      End Using
  End Sub


It just keeps timing out.

However, if I run the query used in the spGetLogs stored procedure to get a count of records, it is only 191,000.

Is there something wrong with the code below?

I will be happy to post the query inside the spGetLogs stored procedure.

I have been thrust into a demo of this app on Monday.

In fact, we went through this with the users a couple of hours ago and now I run into this huge issue.

Any assistance is greatly appreciated.

Viewing all articles
Browse latest Browse all 3938

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>