Is there a way to extend the timeout on a SqlConnection GetSchema() query?

c#, schema, sql, sql-server

Solution

I am guessing that your current user might not have the permissions necessary for this command.

Have you tried:

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

Does that have any results?

Also you should try using the user description to avoid all the sys tables. It might make the query smaller.

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

Problem

The call that I am attempting to make is ``` DataTable dt = connection.GetSchema("Columns"); ``` but I am getting a timeout on the query. Is there a way to increase the timeout on this call? The connection to the database itself gets opened just fine, so the connection timeout isn't going to help me any. I've also seen that there is a CommandTimeout property for SqlCommand, but I don't know if that's really applicable here. So is there a way that I can extend the timeout on the `GetSchema` call? Any help is appreciated!

Original source