テーブルのスキーマ名を取得または設定します。
名前空間:Microsoft.Web.Management.DatabaseManager
アセンブリ: Microsoft.Web.Management.DatabaseManager (Microsoft.Web.Management.DatabaseManager.dll内)
構文
'Declaration
Public Property Schema As String
'Usage
Dim instance As Table
Dim value As String
value = instance.Schema
instance.Schema = value
public string Schema { get; set; }
public:
property String^ Schema {
String^ get ();
void set (String^ value);
}
function get Schema () : String
function set Schema (value : String)
プロパティ値
型: System.String
テーブルのスキーマ名。
注釈
Schema プロパティは、データベース内のテーブルのスキーマの名前を指定します。
例示
次のコード サンプルでは、データベース マネージャーが提供する接続文字列を使用して、OLEDB 接続のテーブルの一覧を取得する GetTables メソッドを実装します。
Public Function GetTables(ByVal connectionString As String) As System.Collections.Generic.ICollection(Of Table) Implements Microsoft.Web.Management.DatabaseManager.IDbTableManager.GetTables
Dim tables As List(Of Table) = New List(Of Table)
' Create a connection to the database.
Dim connection As OleDbConnection = New OleDbConnection(connectionString)
' Open the connection to the database.
connection.Open()
Dim restrictions() As String = New String((4) - 1) {}
restrictions(3) = "TABLE"
' Open the schema information for the tables.
Dim schema As DataTable = connection.GetSchema(OleDbMetaDataCollectionNames.Tables, restrictions)
' Enumerate the list of tables.
For Each row As DataRow In schema.Rows
' Create a new table object.
Dim table As Table = New Table
' Specify the table name.
table.Name = CType(row("TABLE_NAME"), String)
' Test for a creation date.
If Not DBNull.Value.Equals(row("DATE_CREATED")) Then
' Create a date/time object.
Dim createDate As DateTime = New DateTime
' Parse the creation date for the table.
If DateTime.TryParse(row("DATE_CREATED").ToString, createDate) Then
' Specify the creation date for the table.
table.CreateDate = createDate
End If
End If
' Specify the table schema.
If Not DBNull.Value.Equals(row("TABLE_SCHEMA")) Then
table.Schema = CType(row("TABLE_SCHEMA"), String)
Else
table.Schema = String.Empty
End If
' Add the table to the list of tables.
tables.Add(table)
Next
' Return the list of tables.
Return tables
End Function
// Retrieve the list of tables.
public ICollection<Table> GetTables(string connectionString)
{
List<Table> tables = new List<Table>();
// Create a connection to the database.
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
// Open the connection to the database.
connection.Open();
string[] restrictions = new string[4];
restrictions[3] = "TABLE";
// Open the schema information for the tables.
DataTable schema = connection.GetSchema(OleDbMetaDataCollectionNames.Tables, restrictions);
// Enumerate the list of tables.
foreach (DataRow row in schema.Rows)
{
// Create a new table object.
Table table = new Table();
// Specify the table name.
table.Name = (string)row["TABLE_NAME"];
// Test for a creation date.
if (row["DATE_CREATED"] != DBNull.Value)
{
// Create a date/time object.
DateTime createDate = new DateTime();
// Parse the creation date for the table.
if (DateTime.TryParse(row["DATE_CREATED"].ToString(),out createDate))
{
// Specify the creation date for the table.
table.CreateDate = createDate;
}
}
// Specify the table schema.
table.Schema = (string)(row["TABLE_SCHEMA"] == DBNull.Value ? String.Empty : row["TABLE_SCHEMA"]);
// Add the table to the list of tables.
tables.Add(table);
}
}
// Return the list of tables.
return tables;
}
権限
- 直接呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されたコードでは使用できません。 詳細については、「部分信頼コード からのライブラリの使用の」を参照してください。
こちらもご覧ください
リファレンス
テーブル クラス を する