Timeout when populating DataSet via SqlDataAdapter

I retrieve data from SQL through a stored procedure.

It takes 43 seconds to complete in my SQL query window.

But while I execute the same stored procedure through C #, I can not get the answer in 5 minutes.

I am using SqlDataAdapter

using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { DataSet ds = new DataSet(); // Fill the DataSet using default values for DataTable names, etc da.Fill(ds); // Detach the SqlParameters from the command object, so they can be used again cmd.Parameters.Clear(); if (mustCloseConnection) connection.Close(); // Return the dataset return ds; } 

Please help me.

+4
source share
1 answer

Your DateTimePicker is in this format: dd / MM / yyyy.

The standard SQL dates are in this format: MM / dd / yyyy.

Use this for your SP:

 myDateTimePicker.Value.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture) 
0
source

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


All Articles