Is there a way to extend the timeout of a SqlConnection GetSchema () request?

The call I'm trying to make

DataTable dt = connection.GetSchema("Columns"); 

but I get a timeout in the request. Is there a way to increase the timeout on this call?

Connecting to the database itself is very easy to open, so the connection timeout will not help me.

I also saw that there is a CommandTimeout property for SqlCommand, but I do not know if this is really applicable here.

So, is there a way to extend the timeout when calling GetSchema ? Any help is appreciated!

+4
source share
2 answers

I assume that your current user may not have the permissions required for this command.

You tried:

 DataTable dt = connection.GetSchema("Columns", new string[] {null, null, "MyTable"); 

Are there any results?

You should also try using a user description to avoid all sys tables. This may make the request smaller.

 DataTable dt = connection.GetSchema("Columns", new string[] {null, "dbo", null); 
+3
source

no, there is no way to change the timeout for .getschema (). it is designed that way, I think, although I don’t know why. it's 180 seconds.

however, you can query the schema table to get the same information using sqlcommand, where you can use the timeout.

+3
source

All Articles