5

I am executing stored procedure using ExcuteReader() command. If I execute Stored Procedure in SQL server it is taking 2 secs. But in code taking around 2 mins. I tried DataAdapter.Fill(). Still the same.

What is wrong in the code?

        spString = "usp_graph"
        sqlcmd_q.Connection = sqlCnn
        sqlcmd_q.CommandText = spString
        sqlcmd_q.CommandType = CommandType.StoredProcedure
        sqlcmd_q.Parameters.AddWithValue("@clientid", clientId)
        sqlcmd_q.Parameters.AddWithValue("@store", storeID)
        sqlcmd_q.Parameters.AddWithValue("@attributes", attributeNumber)
        sqlcmd_q.Parameters.AddWithValue("@attri1_idx", attribute1_idx)sqlCnn.Open()
        sqlcmd_q.CommandTimeout = 300

        sqldr = sqlcmd_q.ExecuteReader() // taking time here
        dt.Load(sqldr)
        dsGrid.Tables.Add(dt)
1
  • Are you doing anything like set dateformat in your stored proc? I've come across stored procs with a set dateformat slowing things down, yet it will run fine in SSMS when the query is cached. Commented Jun 2, 2011 at 20:43

1 Answer 1

5

Slow in the Application, Fast in SSMS?. Everything you need to know about this subject, and more.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.