Introduction:
The purpose of this tutorial is to demonstrate the use of Monstarillo in a real world scenario. We will be generating code to access the stored procedures that are in the Northwind database. As you will see, most of the code will be generated for you by Monstarillo and will take only a fraction of the time it would take to write yourself.
This tutorial should take about 30 minutes to complete.
There is an online support forum dedicated to this case study.
Database setup:
We will be using the Northwind database for this tutorial.
Create a C# windows project and take note of its location.
Run Monstarillo and enter the database connection information.

Click the Generate Code using existing Stored Procedures button.

Change the output path to the location of your new project. We will be using YellowbridgeSoftwareInc as the base namespace for this tutorial.
Press the Generate Store Procedure Wrappers button. Keeping the Show Files checkbox checked will have Monstarillo open an instance of Windows Explorer and show you the files that have been created for you.
Open your C# application and add a new class called Sprocs. Add the following to the top of the file:
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
Next we will need to add a connection object to our class. The code generated by Monstarillo will use this connection. Add the following code to the class:
private SqlConnection _cn;
Modify the constructor so that it accepts a string called ConnectionString.
Add the following code to the class' constructor to set up the connection string for our _cn variable.
_cn = new SqlConnection();
_cn.ConnectionString = ConnectString;
Your code window should look similar to the following:

Next we will add the code that Monstarillo has generated for us. Place the cursor on the line following the closing brace of the class' constructor. Select Edit -> Insert File as Text from the menu. When the Insert file dialog comes up surf to the SPROC folder in your application directory. Monstarillo puts the generated code in a folder names SPROC under the folder you selected for your output. Select the SprocFile.cs file. To format the code press CTRL + A to select all of the code. Select Edit -> Advanced -> Format Selection from the menu.
You will notice that two methods have been created for each stored procedure. One of the methods returns an int. The int that is returned is the return value from the stored procedure. This method is good to use for stored procedures that do not return data. The second method returns a Data Table. This method is good for methods that return data.
Add an Application Configuration file to the project.

Next we will add an appSettings section to the app.config and add a ConnectionString key to it. Modify the app.config file so that is looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="ConnectionString" value="data source=(local);initial catalog=northwind
;integrated security=SSPI;persist security info=False;packet size=4096" />
</appSettings></configuration>
Add a datagrid to the Form1 form.
Add a button to the Form1 form. Double click on the button to add code to the button's click event. Add the following code to the button's click event handler.
Sprocs sprocs = new Sprocs(
System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"].ToString()
);
dataGrid1.DataSource = sprocs.CustOrderHist_DataTable( "ALFKI");
Notice that you have passed a database connection string to the constructor of the Sprocs object. All that is required is to pass the appropriate parameters to the CustOrderHist_DataTable method.
Run the application and press the button. Notice that the grid is filled with data from the CustOrderHist stored procedure.

Conclusion:
We have seen how easy it is to create wrappers for existing stored procedures using Monstarillo. We have seen how simple it is to use the code generated by Monstarillo.
For more information on Monstarillo visit http://www.yellow-bridge.com .
Discuss Monstarillo with others at http://forums.yellow-bridge.com .