SqlDataAdapter.Fill () Timeout - Basic Sproc returns quickly

I have a SqlDataAdapter that is populated with 21 rows of data (4 columns). The sproc that manages it returns in a couple of seconds to SQL Mgmt Studio, but .Fill () takes 5 minutes.

    ArrayList ret = new ArrayList();
    SqlDataAdapter da = null;
    SqlCommand cmd = null;  
        cmd = base.GetStoredProc("usp_dsp_Stuff"); //Returns immediately in MSSMS.
        cmd.CommandTimeout = 3600; // Set to 6 min - debug only
        base.AddParameter(ref cmd, "@Param1", ParameterDirection.Input, SqlDbType.BigInt, 8, 19, 0, theParam1);
        base.AddParameter(ref cmd, "@Param2", ParameterDirection.Input, SqlDbType.BigInt, 8, 19, 0, theParam2);
        base.AddParameter(ref cmd, "@Param3", ParameterDirection.Input, SqlDbType.Char, 1, 'C');
        da = new SqlDataAdapter(cmd);
        DataTable dt = new DataTable();
        da.Fill(dt); //Takes 5 minutes.

Any ideas?

Thanks in advance! -Chris

+3
source share
6 answers

, , 7 ! . , SQL, . 3500 1 , Fill() #. , , . , - , .NET , SQL, , , . , 100%, , .

+3

. (nolock) , sproc:

FROM category_tbl c INNER JOIN dbo.categoryItem_LNK cl WITH (NOLOCK) ON c.categoryid = cl.categoryid

, SqlDataAdapter, .

,

+2

, (NOLOCK) , , , , / . SQL - .

(, , ) , , SSMS, , . SQL Profiler, , .

- , , SSMS . .

+1
da = new SqlDataAdapter(cmd);
da.SelectCommand.CommandTimeout = 1800;
+1

() , .NET , .

SQL Profiler , SQL.NET Fill().

SET,

set concat_null_yields_null on
set cursor_close_on_commit off
set implicit_transactions off

etc...

.. , , .

0

Source: https://habr.com/ru/post/1706746/


All Articles