Can the GetSchema method work asynchronously?

How does a class GetSchemaclass work SqlConnection? Does the request fulfill? Is it possible to call it asynchronously?

+3
source share
3 answers

Assuming you want a C # answer, as it is in your tag, see: Use SqlConnection.GetSchema to get only tables (no views)

    using System.Data.SqlClient;

and

    SqlConnection.GetSchema("Tables");

or

    SQLCon.Open();
    DataTable tables = SQLCon.GetSchema("Tables");
    SQLCon.Close();

I would guess that this is actually executing a query for sys or information_schema.tables tables in SQL when opening a connection. sort of:

   SELECT * FROM information_schema.tables 

or

    SELECT * FROM [database].sys.tables

And the equivalent calls other methods inside the class.

For Async calls you can use

    Asynchronous Processing=True; 

in the connection string

    string connectionString = "Data Source=yourDataSource;Initial Catalog=yourCat;Integrated Security=true;Asynchronous Processing=True;";

Is this the answer to your question?

+3
source
0

All Articles