ADO.NET Sample

This sample consist of a command line showing how to interact with a database.

The DataReader object is somewhat synonymous with a read-only/forward-only cursor over data. The DataReader API supports flat as well as hierarchical data. A DataReader object is returned after executing a command against a database. The format of the returned DataReader object is different from a recordset. For example, you might use the DataReader to show the results of a search list in a web page.


To compile the example:

  1. Launch EiffelStudio.
  2. Select Use existing Ace (control file) and click OK
  3. Browse to $ISE_EIFFEL\examples\dotnet\ado\ado3\
  4. Choose the Ace file for the version of the .net framework you are running
  5. Choose the directory where the project will be compiled, by default the same directory containing the Ace file.
  6. Click OK.


After you launch the sample, the following output appears:Customer ID Company Name ALFKI Alfreds Futterkiste ANATR Ana Trujillo Emparedados y helados ANTON Antonio Moreno Taquera AROUT Around the Horn BERGS Berglunds snabbkp BLAUS Blauer See Delikatessen BLONP Blondesddsl p`re et fils BOLID Blido Comidas preparadas BONAP Bon app' BOTTM Bottom-Dollar Markets BSBEV B's Beverages CACTU Cactus Comidas para llevar CENTC Centro comercial Moctezuma CHOPS Chop-suey Chinese COMMI Comrcio Mineiro CONSH Consolidated Holdings DRACD Drachenblut Delikatessen DUMON Du monde entier EASTC Eastern Connection ... ... ... WILMK Wilman Kala WOLZA Wolski Zajazd

When the display is finished, the application wait for you to pressed the return key to finish the application.

Under the Hood

This application shows how to interact with a database. First the connection to the database is opened: create connection.make ("server=(local)\NetSDK;Trusted_Connection=yes;database=northwind")Then a request to the database is made: create command.make ("select * from customers", connection) reader := command.execute_reader Finally, the result of the request is displayed: from ok := until not ok loop io.put_string (reader.item ("CustomerID").to_string) io.put_string ("%T%T") io.put_string (reader.item ("CompanyName").to_string) io.new_line ok := end

This sample uses the following ADO.NET classes:



This sample is translated from the example located in the QuickStart\howto\samples\adoplus subdirectory of the .NET Framework SDK samples directory of Microsoft Visual Studio .NET.