スケーラブルデータベースサーバ HiRDB Version 8 UAP開発ガイド
表のデータをすべて表示する例を次に示します。
プログラム例はVisual C# .NETで記述していますが,Visual Basic.NETでもほぼ同じ内容です。必要に応じて,読み替えてください。
using System; using System.Data; using Hitachi.HiRDB; namespace test_C { class Sample { [STAThread] static void Main(string[] args) { try { // Connectionオブジェクトを作成する HiRDBConnection cn = new HiRDBConnection("dsn=pc;"); // DBに接続する cn.Open(); // Commandオブジェクトを作成する HiRDBCommand cm = new HiRDBCommand(); cm.Connection = cn; cm.CommandText = "select a from ex"; // DataReaderオブジェクトを作成する HiRDBDataReader rd = cm.ExecuteReader(); ...............1 int i; while(rd.Read()) { for (i = 0 ; i < rd.FieldCount ; i++) { Console.WriteLine(rd.GetName(i) + " - " +rd.GetValue(i)); } } ......................................................2 // DBから切断する cn.Close(); } catch ( HiRDBException ex) { Console.WriteLine(ex); } catch ( System.Exception ex) { Console.WriteLine(ex); } } } } |
All Rights Reserved. Copyright (C) 2006, 2016, Hitachi, Ltd.