The content of those articles will help you understand and be able to complete the steps in this article to begin to apply the use of Mono in more practical and useful ways. As covered before Mono (and .NET) can be used to create and deliver very feature rich web content. In this article we will see how to use Mono to access databases, an activity at the very heart of many solutions.

Configuring ADO.NET for MySQL (this assumes that the exercises in the first 2 articles in this series have been completed successfully). This article also assumes a working knowledge of MySQL databases and administration.

Using the YaST Control Center go to the Runlevel editor and verify that you have the MySQL database server enabled. You should be able to type mysql at a console window and enter the MySQL Monitor.

In the aspx samples located at /opt/gnome2/share/doc/xsp/test you will see a dbpage1.aspx and a dbpage2.aspx. This section walks you through modifying those applications to work with a MySQL database and the ByteFX driver. They are currently configured to work with the PostgreSQL database and the Mono driver with has been deprecated for MySQL (http://www.go-mono.com/mysql.html).

Basically all you have to do is modify the web.config file in the /opt/gnome2/share/doc/xsp/test and change the DBProviderAssembly from Mono.Data.ProgresClient to ByteFX.Data, and the DBConnectionType from Mono.Data.PostgreSqlClient.PgSqlConnection to ByteFX.Data.MySqlClient.MySqlConnection, and change the DBConnectionString values as follows:

Host Addr to Server and set it equal to localhost
user to User ID
password to Password
dbname to Database

(The ByteFX sample is at http://www.go-mono.com/mysql.html and will help with these settings)

Extract the files from the zip file and place them in the /opt/gnome2/lib directory. You may find that ByteFX.Data.dll already exists in that folder. Over-write the existing in order for the following steps to work correctly.

Note: This following instructions are not necessary if you extracted the ByteFX.Data.dll to the /opt/gnome2/lib directory but are provided here as information or guidance if you are not using the web.config file.

Modify the dbpage1.aspx application and add the following two lines to the import section and make the same changes that you make in the web.config file

You can now click on either dbpage1.aspx or dbpage2.aspx on the Mono ASP samples page to try out the database connectivity. Try out all of the functionality and follow through the source code to get an idea of how it all comes together.

Next time out?

In the next article in this series we'll further examine using databases with Mono and see how to use ASP.NET and ADO.NET together to create web content that is full of features. In the mean time you can look further into Monodoc to find more information about what Mono (and .NET) has to offer developers, visit the Mono Project page on Novell Forge and keep current with all of the activities of the Mono Project as the project home page.