Preparing Your Machine to Work with Strings


Like in all other chapters, the best way to learn about the topic at hand is to create a small project in which you can try new things. For this chapter, however, you may be getting more than you've bargained for. We are going to write a little database application. You don't need a commercially available database like SQL Server or even Access. All the database examples in this book will use MySQL. MySQL is a free, open -source, relational database. It doesn't have all the flashy administration tools that SQL Server has, but it is a very powerful database and it's free!

To talk to MySQL from C# you need to use a .NET database provider. One such tool is a tool called dbProvider by eInfoDesigns, Inc. dbProvider isn't free, but eInfoDesigns offers a scaled-down version of the tool for free. Because a lot of you probably don't have MySQL and dbProvider installed I've divided the instructions for writing the sample application into two topics "Preparing your machine to work with strings" (this one) and "Working with strings" (the next one).

To prepare your machine to run the database samples:

  1. First download MySQL. The company that produces MySQL is called MySQL AB and their URL is www.mysql.com. The download section for the latest version as of the time of this writing is at: http://www.mysql.com/downloads/mysql-3.23.html ( Figure 4.1 ).

    Figure 4.1. You can download the latest version of MySQL from the MySQLWeb site.

    graphics/04fig01.gif

  2. Once you download the file mysql-3.23.51-win.zip, unzip its contents to a temporary directory.

  3. Run setup.exe to install MySQL and follow the instructions ( Figure 4.2 ).

    Figure 4.2. This looks familiar! Just change the title and you have the setup program of your choice.

    graphics/04fig02.jpg

  4. After installing MySQL, install dbProvider. You can get dbProvider from the download section for this book at www.peachpit.com. The file is called dbProvider-Personal-1-5.msi. Doubleclick this file to install the dbProvider ( Figure 4.3 ).

    Figure 4.3. The setup program for dbProvider looks a little different from the standard setup programs. However, I have faith that readers will be able to successfully click the Next button.

    graphics/04fig03.gif

  5. After installing dbProvider, run the file createdb .cmd, which is a script I wrote to create the database for the sample applications. It is also available in the download section in Peachpit's Web site. To run it, double-click on the file from Windows Explorer.

graphics/tick.gif Tips

  • Although the sample code will use MySQL for a database backend, the techniques used for database programming are identical to those used for accessing SQL Server or Oracle, for example.

  • The samples in this chapter will use ADO.NET to talk to the database. ADO.NET is a library of functions that Microsoft ships with the .NET framework for accessing databases. For you to access a database through ADO.NET, the vendor of the database has to write what is called a data provider. You may have heard of other technologies for accessing databases such as ODBC or OLE DB. ADO.NET data providers have the same goals as ODBC and OLE DB providers to use the same functions to access any type of database. MySQL doesn't have any native ADO.NET providers as of the writing of this book, which is why we need a third-party tool like dbProvider.




C#
C# & VB.NET Conversion Pocket Reference
ISBN: 0596003196
EAN: 2147483647
Year: 2003
Pages: 198
Authors: Jose Mojica

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net