RDM Server 8.4 ADO .NET Interface Guide Trademarks Raima®,Raima Database Manager®,RDM®,RDM Embedded®and RDM Server®are trademarksofRaima Inc.and may be registered in the United StatesofAmerica and/orothercountries.All othernamesreferenced herein may be trademarksof theirrespective owners. Thisguide may contain linksto third-party Web sitesthat are not underthe control ofRaima Inc.and Raima Inc.isnot responsible forthe content on any linked site.Ifyou accessa third-party Web site mentioned in thisguide,you do so at your own risk.Inclusion ofany linksdoesnot imply Raima Inc.endorsement oracceptance ofthe content ofthose third-party sites. Contents Contents Contents i Introductionto ADO.NET 1 Basic ADO.NETApplication Steps 1 Hello World! 2 Getting StartedwithADO.NET 4 Registering the Raima.Rdms.dll 4 Command Line 4 Visual Studio GUI 5 Using DbProviderFactory 5 RdmsCommandClass 9 RdmsCommand()Constructor 11 RdmsCommand(RdmsConnection)Constructor 12 RdmsCommand(string)Constructor 13 RdmsCommand(string,RdmsConnection)Constructor 14 IDbCommand.Connection Property 15 IDbCommand.CreateParameter()Method 16 IDbCommand.ExecuteReader()Method 17 ExecuteReader(CommandBehavior)Method 18 IDbCommand.ParametersProperty 19 IDbCommand.Transaction Property 20 Cancel()Method 21 CreateParameter()Method 22 ExecuteNonQuery()Method 23 ExecuteReader()Method 24 ExecuteReader(CommandBehavior)Method 25 ExecuteScalar()Method 26 Prepare()Method 27 CommandText Property 28 CommandTimeout Property 29 CommandType Property 30 Connection Property 31 ParametersProperty 32 Transaction Property 33 UpdatedRowSource Property 34 RdmsConnectionClass 35 RdmsConnection()Constructor 37 RdmsConnection(string)Constructor 38 StateChange Event 39 IDbConnection.BeginTransaction()Method 40 IDbConnection.BeginTransaction(IsolationLevel)Method 41 ADO .NET UserGuide i Contents IDbConnection.CreateCommand()Method 42 BeginTransaction()Method 43 BeginTransaction(IsolationLevel)Method 44 BeginTransaction(string)Method 45 BeginTransaction(string,IsolationLevel)Method 46 ChangeDatabase(string)Method 47 Close()Method 48 CreateCommand()Method 49 EnlistTransaction(Transaction)Method 50 GetSchema()Method 51 GetSchema(string)Method 52 GetSchema(string,string[])Method 53 Open()Method 58 AutoCommit Property 59 ConnectionString Property 60 Connection Timeout Property 61 Database Property 62 DataSource Property 63 ServerVersion Property 64 State Property 65 RdmsConnectionStringBuilder Class 66 RdmsConnectionStringBuilder()Constructor 68 RdmsConnectionStringBuilder(string)Constructor 69 Add(string,Object)Method 70 Clear()Method 71 ContainsKey(string)Method 72 EquivalentTo(DbConnectionStringBuilder)Method 73 Remove(string)Method 74 ShouldSerialize(string)Method 75 TryGetValue(string,out Object)Method 76 AutoCommit Property 77 BrowsableConnectionString Property 78 ConnectionString Property 79 Count Property 80 Database Property 81 Host Property 82 IsFixedSize Property 83 IsReadOnly Property 84 ItemProperty 85 KeysProperty 86 Password Property 87 ADO .NET UserGuide ii Contents Port Property 88 UserProperty 89 ValuesProperty 90 RdmsDataAdapter class 91 RdmsDataAdapter()Constructor 93 RdmsDataAdapter(RdmsCommand)Constructor 94 RdmsDataAdapter(string,RdmsConnection)Constructor 95 RdmsDataAdapter(string,string)Constructor 96 RowUpdated Event 97 RowUpdating Event 98 IDbDataAdapter.DeleteCommand Property 99 IDbDataAdapter.InsertCommand Property 100 IDbDataAdapter.SelectCommand Property 101 IDataAdapter.TableMappingsProperty 102 IDbDataAdapter.UpdateCommand Property 103 Fill(DataSet)Method 104 Fill(DataTable)Method 105 Fill(DataSet,string)Method 106 Fill(int,int,DataTable[])Method 107 Fill(DataSet,int,int,string)Method 108 FillSchema(DataSet,SchemaType)Method 109 FillSchema(DataTable,SchemaType)Method 110 FillSchema(DataSet,SchemaType,String)Method 111 GetFillParameters()Method 112 Update(DataRow[])Method 113 Update(DataSet)Method 114 Update(DataTable)Method 115 Update(DataSet,String)Method 116 DeleteCommand Property 117 InsertCommand Property 118 SelectCommand Property 119 UpdateBatchSize Property 120 UpdateCommand Property 121 RdmsDataReader Class 122 IDataRecord.GetData(int ordinal)Method 124 Close()Method 125 GetBoolean(int)Method 126 GetByte(int)Method 127 GetBytes(int,long,byte[],int,int)Method 128 GetChar(int)Method 130 GetChars(int,long,char[],int,int)Method 131 ADO .NET UserGuide iii Contents GetData(int)Method 133 GetDataTypeName(int)Method 134 GetDateTime(int)Method 135 GetDecimal(int)Method 136 GetDouble(int)Method 137 GetEnumerator()Method 138 GetFieldType(int)Method 139 GetFloat(int)Method 140 GetGuid(int)Method 141 GetInt16(int)Method 142 GetInt32(int)Method 143 GetInt64(int)Method 144 GetName(int)Method 145 GetOrdinal(string)Method 146 GetProviderSpecificFieldType(int)Method 147 GetProviderSpecificValue(int)Method 148 GetProviderSpecificValues(Object[])Method 149 GetSchemaTable()Method 150 GetString(int)Method 151 GetValue(int)Method 152 GetValues(Object[])Method 153 IsDBNull(int)Method 154 NextResult()Method 155 Read()Method 156 Command Property 157 Depth Property 158 FieldCount Property 159 HasRowsProperty 160 IsClosed Property 161 Item[int]Property 162 Item[string]Property 163 RecordsAffected Property 164 VisibleFieldCount Property 165 RdmsParameter Class 166 RdmsParameter()Constructor 167 RdmsParameter(string,Object)Constructor 168 RdmsParameter(string,RdmsType)Constructor 169 IDbDataParameter.Precision Property 170 IDbDataParameter.Scale Property 171 ResetDbType()Method 172 ResetRdmsType()Method 173 ADO .NET UserGuide iv Contents DbType Property 174 Direction Property 175 IsNullable Property 176 ParameterName Property 177 RdmsType Property 178 Size Property 179 SourceColumn Property 180 SourceColumnNullMapping Property 181 SourceVersion Property 182 Value Property 183 RdmsParameterCollectionClass 184 IDataParameterCollection.Item[string]Property 186 IList.Item[int]Property 187 Add(Object)Method 188 Add(RdmsParameter)Method 189 AddRange(Array)Method 190 AddRange(RdmsParameter[])Method 191 Add(string,Object)Method 192 Add(string,RdmsType)Method 193 Clear()Method 194 Contains(Object)Method 195 Contains(RdmsParameter)Method 196 Contains(string)Method 197 CopyTo(Array,int)Method 198 CopyTo(RdmsParameter[],int)Method 199 GetEnumerator()Method 200 IndexOf(Object)Method 201 IndexOf(RdmsParameter)Method 202 IndexOf(string)Method 203 Insert(int,Object)Method 204 Insert(int,RdmsParameter)Method 205 RemoveAt(int)Method 206 RemoveAt(string)Method 207 Remove(Object)Method 208 Remove(RdmsParameter)Method 209 Count Property 210 IsFixedSize Property 211 IsReadOnly Property 212 IsSynchronized Property 213 Item[int]Property 214 Item[string]Property 215 ADO .NET UserGuide v Contents SyncRoot Property 216 RdmsRowUpdatedEventArgsClass 217 RdmsRowUpdatedEventArgs(DataRow,IDbCommand,StatementType,DataTableMapping)Constructor 218 Command Property 219 RdmsRowUpdatingEventArgsClass 220 RdmsRowUpdatingEventArgs(DataRow,IDbCommand,StatementType,DataTableMapping)Constructor 221 Command Property 222 RdmsTransactionClass 223 Commit()Method 224 Rollback()Method 225 Connection Property 226 IsolationLevel Property 227 RdmExceptionClass 228 Procedure Property 229 SqlState Property 230 RdmsRowUpdatedEventHandlerDelegate 231 RdmsRowUpdatingEventHandlerDelegate 232 RdmsType Enumeration 233 ADO .NET UserGuide vi Introduction to ADO .NET Introduction to ADO .NET The RDMsdatabase management system(DBMS)isdesigned to provide powerful,flexible,high-performance capabilitiesfor developing embedded database applications.By combining the network and relational model technologiesin a single system, RDMsletsyou organize and accessinformation efficiently,regardlessofthe complexity ofthe data.The Native RDMsC API providesan efficient low-level interface with a rich set offunctionality. The ADO.NETinterface to RDMsisdesigned to allow developersto accessthispowerful DBMSfromADO.NETand there- fore fromany application running in the CLR and fromany .NETlanguage. Thisinterface isan ADO.NETData Providerand can integrate into the .NETDbProviderFactoriesability orcan be referenced directly.The following classesencompassthe RDM ServerData Provider. RdmsConnection class l RdmsConnectionStringBuilderClass l RdmsCommand class l RdmsDataReaderclass l RdmsParameterclass l RdmsParameterCollection class l RdmsDataAdapterclass l RdmsTransaction class l RdmsException Class l RdmsType enumeration l RdmsRowUpdatedEventArgsclass l RdmsRowUpdatingEventArgsclass l RdmsRowUpdatedEventHandlerdelegate l RdmsRowUpdatingEventHandlerdelegate l Basic ADO.NET Application Steps An ADO.NETC# application programconsistsofa set ofcallsto the ADO.NETAPIfunctionsin a particularsequence as outlined below. 1. Set up and initialize yourapplication’suse ofthe ADO.NETAPIasfollows. a. Create a String object to define yourconnection string in the following format: "host- t=localhost;database=hello_worldADO" b. Create an RdmsConnection object to handle yourconnection to the Raima database systemand passin your connection string to the constructor. c. Create an RdmsCommand object to handle yourSQLcommandsyou wish to use to interact with the RDMs database system. d. Create an RdmsTransaction object to handle yourtransactionswithin the RDMsdatabase system. e. Create an RdmsDataReaderobject to handle reading out data fromthe RDMsdatabase system. f. Call the Open function ofthe RdmsConnection object in orderto open yourdatabase. 2. Prepare yourapplication to execute SQLstatementsasfollows. a. Set the CommandText property ofthe RdmsCommand object to define the SQLstatement that will need to be executed by yourapplication. ADO .NET UserGuide 1 Introduction to ADO .NET b. Create some RdmsParameterobjectsforany parametersyou will need forany parametermarkersthat were spe- cified in the SQLstatementsdefined in the priorstep. c. Call the Parameters.Add(param)to bind yourapplication’svariablesto any parameterscreated in step b. 3. At thispoint yourapplication isexecution ready.That meansthat yourapplication will … a. Call ExecuteNonQuery on the RdmsCommand object to execute the appropriate statementsthat implement the database accessneedsforeach particularfunction.Alternatively you can call ExecuteScalarto execute a state- ment and return the first column ofthe first row ofresults. b. Call transaction statementsusing the RdmsTransaction classin orderto start the transaction,commit the trans- action,create a savepoint,orrollback a transaction. c. Call ExecuteReaderto retrieve the result rowsfroman executed select statement.You iterate overthe results using the RdmsDataReaderobject. 4. When yourapplication isready to terminate you need to… a. Call Close on the RdmsDataReaderobject you used ifyou read fromone. b. Call Close on the RdmsConnection object to close the connection to yourdatabase. Hello World! Ifyou follow the basic procedure listed above you can easily create a simple database where you insert some data and the retrieve the data to be displayed back out.Thiscan be seen with the common Hello World example. In the example below return codesare mostly ignored forsimplicity.Thiswill be ok because we know what the expected res- ultsare. /********************************************************************* ** HELLO WORLD ADO.NET ** --------------- ** This document describes the process to open a simple database, insert a record ** containing a text field, read the text field from database and print it out. **********************************************************************/ using System; using Raima.Rdms; /* The RDM ADO.NET API */ using System.Data; namespace HelloWorldApplication { class HelloWorld { static void Main() { /* Setup connection and SQL query strings */ string connectionString = "host=localhost;database=hello_worldADO"; string insertString = "INSERT INTO info(myChar) VALUES('Hello World!')"; string queryString = "SELECT myChar FROM info"; /* Create connection object to connect to the database */ RdmsConnection connection = new RdmsConnection(connectionString) /* Create a command object to call SQL queries */ RdmsCommand command = connection.CreateCommand(); /* Create a transaction object to start and stop transactions */ RdmsTransaction rdmtrans = null; ADO .NET UserGuide 2
Description: