This identifier has a low probability of being duplicated as it is composed of a 128-bit integer (16 bytes) that can be used across all computers and networks wherever a unique identifier is required.) You supply a value from the OleDbSchemaGuid enumeration to specify the type of schema information you want, such as tables, columns, and procedures. The GetOleDbSchemaTable method returns schema information from a data source as indicated by a Guid.( A GUID represents a globally unique identifier (GUID). We're going to let the connection object get the information for us. When we retrieve schema information with OleDb, we don't need a DataAdapter. SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM Information_Schema.Tables where Table_Type = 'BASE TABLE'", cn") ĭa.Fill(dt) Using OleDbConnection.GetOleDbSchemaTable Method SqlConnection cn = new SqlConnection("PutYourConnectionStringOverHere") You can execute the following piece of code to retrieve information regarding the various tables on your SQL Server database: However do remember that for information schema views, the metadata returned is limited to that which the user has permission to view. You simply query Sql Server's Information_Schema and restrict the results to Table_Type = 'BASE TABLE' or Table_Type = 'VIEW'. NET Data Provider exposes backend schema information through stored procedures and informational views. There is no direct equivalent to this feature in the SQL Client. GetOleDbSchemaTable returns a DataTable that is populated with the schema information. The OleDbConnection object exposes a GetOleDbSchemaTable method that you can use to retrieve schema information for your database, such as a list of tables or columns. These two classes retrieve the table schema differently. NET, you either use the class or the class. By using the database schema information, you can see the database structure and all the data in it. The database schema also known as metadata, is how the database defines itself. In this article, I will describe the ways to retrieve the database schema information using class and the class. This information is called Database Metadata. At times, in addition to querying and updating data in a database, you also need to retrieve information about the database as well as its contents.
0 Comments
Leave a Reply. |