DataTableReader.GetDataTypeName メソッド
アセンブリ: System.Data (system.data.dll 内)
構文Dim instance As DataTableReader Dim ordinal As Integer Dim returnValue As String returnValue = instance.GetDataTypeName(ordinal)
戻り値
列のデータ型を示す文字列。
例外
解説
使用例次に示すコンソール アプリケーションでは、単純な DataTable から取得したフィールドとそのデータ型名の一覧が表示されます。
Private Sub TestGetTypeName() Dim table As DataTable = GetCustomers() Using reader As New DataTableReader(table) For i As Integer = 0 To reader.FieldCount - 1 Console.WriteLine("{0}: {1}", _ reader.GetName(i), reader.GetDataTypeName(i)) Next End Using Console.WriteLine("Press Enter to finish.") Console.ReadLine() End Sub Private Function GetCustomers() As DataTable ' Create sample Customers table, in order ' to demonstrate the behavior of the DataTableReader. Dim table As New DataTable ' Create two columns, ID and Name. Dim idColumn As DataColumn = table.Columns.Add("ID", _ GetType(Integer)) table.Columns.Add("Name", GetType(String)) ' Set the ID column as the primary key column. table.PrimaryKey = New DataColumn() {idColumn} table.Rows.Add(New Object() {1, "Mary"}) table.Rows.Add(New Object() {2, "Andy"}) table.Rows.Add(New Object() {3, "Peter"}) table.Rows.Add(New Object() {4, "Russ"}) Return table End Function
private static void TestGetTypeName() { DataTable table = GetCustomers(); using (DataTableReader reader = new DataTableReader(table)) { for (int i = 0; i < reader.FieldCount; i++) { Console.WriteLine("{0}: {1}", reader.GetName(i), reader.GetDataTypeName(i)); } } Console.WriteLine("Press Enter to finish."); Console.ReadLine(); } private static DataTable GetCustomers() { // Create sample Customers table, in order // to demonstrate the behavior of the DataTableReader. DataTable table = new DataTable(); // Create two columns, ID and Name. DataColumn idColumn = table.Columns.Add("ID", typeof(int)); table.Columns.Add("Name", typeof(string )); // Set the ID column as the primary key column. table.PrimaryKey = new DataColumn[] { idColumn }; table.Rows.Add(new object[] { 1, "Mary" }); table.Rows.Add(new object[] { 2, "Andy" }); table.Rows.Add(new object[] { 3, "Peter" }); table.Rows.Add(new object[] { 4, "Russ" }); return table; }
プラットフォームWindows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照Weblioに収録されているすべての辞書からDataTableReader.GetDataTypeName メソッドを検索する場合は、下記のリンクをクリックしてください。
全ての辞書からDataTableReader.GetDataTypeName メソッド
を検索
- DataTableReader.GetDataTypeName メソッドのページへのリンク