The initial thing we need is to create our database connection string. In most cases (if not all), I have a preference to employ the Web.config file to define my database connection string. If you are not familiar with this approach, take a moment to look at page 5 of my previous article, titled Read and Write BLOB Data to a Database Table with ODP.NET.

This now brings us to the point of creating a method that will process the data entry from our Web form that we previously created. For the purpose of this article we I created a private method named ProcessAuthors that will handle this task.

The CommandText is set to the stored procedure name Authors_Array. (CommandText may be either a SQL statement or a stored procedure.)

The CommandType is defined as a StoredProcedure.

The data input via the Web Form is captured. I achieve this by defining a string named author1Email, author1Name, and so on. In this case I have three entries for author information.

Two separate string arrays are initialized, one for the author’s email address and the other for the author’s name.

This now brings us to the vital step that must be defined correctly for all this to work as a single round trip to our database. The OracleCommand member ArrayBindCount is the array binding feature that in turn specifies the number of array elements that will be bound to our OracleParameter value. In this case, it is three since we have three elements in our arrays.

Next an OracleParameter is established for each item that is to be inserted into the database.

The database call is executed by using the ExecuteNonQuery method of the OracleCommand class. Notice that I have wrapped the statement in a try-catch-finally statement because you always want to catch and handle any exceptions that may be thrown.

Finally, the database connection is returned back to the pool with the finally statement by using the Dispose method of the OracleConnection class.