James123
James123

Reputation: 11672

ExecuteReader taking time, not in SQL server?

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)

Upvotes: 5

Views: 2693

Answers (1)

Remus Rusanu
Remus Rusanu

Reputation: 294487

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

Upvotes: 5

Related Questions