angel uc
angel uc

Reputation: 279

connect timeout=0???? what about? timeout value expired with 1500

System.Data.SqlClient.SqlConnection conec = new System.Data.SqlClient.SqlConnection("data source=" + servidor + "; initial catalog=" + basedatos + "; user id=" + usuario + "; password=" + contra + "; Connect Timeout=1500;  Packet Size=32767; ");

that is my connection but i got timeout value expired i changed it to 0 and i got the same message but when i changed it to my sqlcommand

System.Data.SqlClient.SqlCommand comando = new System.Data.SqlClient.SqlCommand(consulta, conexion);
            comando.CommandTimeout = 0;

it works ok, why doesn´t it work if i have 0 in my connection string? what is the difference? i have listen about connection lifetime but i don't have idea about it.

Upvotes: 0

Views: 11226

Answers (2)

to StackOverflow
to StackOverflow

Reputation: 124746

You can set the Connection Timeout, i.e. the maximum time to wait while establishing a connection, in the Connection String.

You can not set CommandTimeout, the maximum time for a command to complete execution, in the connection string: this has to be set in code.

Upvotes: 2

D'Arcy Rittich
D'Arcy Rittich

Reputation: 171491

Try using:

Connection Timeout=1500

instead of:

Connect Timeout=1500

(From the documentation.)

Upvotes: 2

Related Questions