Online Eiffel Documentation
EiffelStudio

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.

Compiling

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.

Running

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 open ( create my_sql_connection . make_from_connection_string ( my_database)), then a request to the database is made (create my_sql_command. make_from_cmd_text_and_connection ( my_command, my_sql_connection )). Finally, the result of the request is displayed.

This sample contains the following class:

Notes

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.