0

When using the following connection string
Server=DoesNotExists; Database=DoesNotExistsEither; User ID=bla; Password=bla; Connection Timeout=5;
shouldn't any command against this connection string fail in 5 seconds?!? in my local machine it's taking about 30sec

Edit1
If i change the timeout to 20, it takes 1 min to fail...

Leonardo
  • 10,737
  • 10
  • 62
  • 155

1 Answers1

1

Command timeout and connection timeout are not the same thing.

  • Connection timeout: maximum time to (try to) establish connection to database
  • Command timeout: maximum time a command is allowed to run

So in short: no, a command against that connectionstring should not fail after 5 seconds, if a connection is established.

See also this post.

martennis
  • 882
  • 11
  • 20
  • if you take a look at the connection string you will see that the connection will never be established because neither the server nor the database exists... – Leonardo Jul 19 '17 at 12:44
  • Ah, I didn't get that :-) – martennis Jul 19 '17 at 12:45
  • @Leonardo, did you take a look at what your `Context.Connection.ConnectionTimeout` or `Context.Database.Connection.ConnectionTimeout` says? – martennis Jul 19 '17 at 12:47