Scalable Database Server, HiRDB Version 8 UAP Development Guide
This example inserts 123, 456, and 789 in the first column of the ex table:
// Create objects such as a connection object HiRDBConnection pConn = new HiRDBConnection("connection-character-string"); HiRDBCommand pCom = pConn.CreateCommand(); // Connect to the database pConn.Open(); // Create a table pCom.Connection = pConn; pCom.CommandText = "create table ex(a int array[3])"; pCom.ExecuteNonQuery(); // Create a parameter object HiRDBParameter pPar = pCom.CreateParameter(); // Set parameters pPar.Direction = ParameterDirection.Input; pPar.HiRDBType = HiRDBType.Integer; object [] aValue = new object[3]; aValue[0] = 123; aValue[1] = 456; aValue[2] = 789; pPar.Value = aValue; pPar.Repetition = (short)aValue.Length; pCom.Parameters.Add(pPar); ........................................1 // Use parameters to execute SQL statement pCom.CommandText = "insert into ex values(?)"; pCom.ExecuteNonQuery(); // Execute the select statement pCom.CommandText = "select * from ex"; HiRDBDataReader pReader = pCom.ExecuteReader(); // Fetch until there is no more data while (pReader.Read()) { for (int i = 0; i < pReader.FieldCount; ++ i) for (int j = 0; j < pReader.GetFieldArrayCount(i); ++ j) Console.WriteLine(pReader.GetValue(i, j)); } .................................................................2 // Disconnect from the database pConn.Close(); |
All Rights Reserved. Copyright (C) 2007, Hitachi, Ltd.