vb.net - Timeout from .NET but not from sql-server console -


I have a query which takes 10 seconds from the sql-server console, but I get timeout from a program written in VB is ). What could be the reason that I get a timeout from my program but works well with the sqlserver console?

My shared code: GetDataSet (ByVal vCommandType as CommandType, ByVal strSQL string, Byval sqlParams New SqlCommaction (Bbdd.connectionString) as DIC new SqlCommand () in the form of DC.CommandTimeout = 600 --- With it, my query works fine DC.CommandText = strSQL DC.CommandType = vCommandType DC.Connection = oConn (SqlParams) if not DC then Parameters. Adrenaline (SKLPRAM) End if the new SQL DTDA (Dc) DIS DA as DMA try new Dataset DA as DA DFFill (DS) returns as DS Exchange Hold oakon at the end. Close () DA Last Function

This is quite common and can be for many reasons. SQL Server probably uses a separate scheme cache for SSMS and your application. And if execution plans are different, the execution time may vary widely.

SQL Server optimizes specific values ​​for the parameter, so if the first query parameter that you send uses a good execution plan, then you are in luck next invention of the same question Will reuse that plan. But it is also possible to choose such parameters, which give poor execution plans. This is called "sniffing the parameter".

For a detailed explanation, see Erland Somersog.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -