<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6441553613064463233</id><updated>2011-09-26T07:44:47.679-07:00</updated><category term='Migrating an ASP.NET application from MS SQL Server To MySQL'/><category term='WCF'/><category term='Noida'/><category term='BrickRed Technologies'/><category term='Dynamic Reports in SQL Server Reporting Services 2008'/><category term='Data Integration'/><category term='Quartz.NET'/><category term='BCP'/><category term='SQL Server'/><title type='text'>Sudhir Dwivedi on .NET</title><subtitle type='html'>This blog is intended to share daily technical intricacies faced by Sudhir Dwivedi.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sudhironline.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6441553613064463233/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://sudhironline.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Sudhir Dwivedi's .NET Blog</name><uri>http://www.blogger.com/profile/03672675458059523580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='http://2.bp.blogspot.com/_5vvvyC6SDJw/SVfhD8QpsnI/AAAAAAAAAA8/yM02BEUraxg/S220/sudhirindubai.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>8</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6441553613064463233.post-4297358190126920111</id><published>2010-12-27T02:18:00.000-08:00</published><updated>2010-12-27T02:35:24.758-08:00</updated><title type='text'>Making Log4Net Work with the .NET Client Profile</title><content type='html'>Hi,&lt;br /&gt;&lt;br /&gt;I was trying to call log4net standard dll in one of my WCF service library project.&lt;br /&gt;But oops! The smart language compiler on VS IDE 2010 was NOT allowing me to write even “using log4net;” on the namespace declaration area.&lt;br /&gt;I knew the solution that to change target framework from .net 4.0 client profile to .net 4.0 on the properties page of the project.&lt;br /&gt;But as you know that client profile is supposed to make your binaries thinner by removing unused references and hence to make faster your app/service.&lt;br /&gt;&lt;br /&gt;So I googled to customize my log4net and here I got the solution.&lt;br /&gt;&lt;br /&gt;Please read the link given below, it worth reading.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.codeproject.com/KB/dotnet/Log4NetWithClient.aspx"&gt;http://www.codeproject.com/KB/dotnet/Log4NetWithClient.aspx&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;Best Regards,&lt;br /&gt;Sudhir K. Dwivedi&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6441553613064463233-4297358190126920111?l=sudhironline.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sudhironline.blogspot.com/feeds/4297358190126920111/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sudhironline.blogspot.com/2010/12/making-log4net-work-with-net-client.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6441553613064463233/posts/default/4297358190126920111'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6441553613064463233/posts/default/4297358190126920111'/><link rel='alternate' type='text/html' href='http://sudhironline.blogspot.com/2010/12/making-log4net-work-with-net-client.html' title='Making Log4Net Work with the .NET Client Profile'/><author><name>Sudhir Dwivedi's .NET Blog</name><uri>http://www.blogger.com/profile/03672675458059523580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='http://2.bp.blogspot.com/_5vvvyC6SDJw/SVfhD8QpsnI/AAAAAAAAAA8/yM02BEUraxg/S220/sudhirindubai.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6441553613064463233.post-5959684838128676338</id><published>2010-03-02T11:37:00.000-08:00</published><updated>2010-03-30T07:40:45.469-07:00</updated><title type='text'>Smiley Face After a Big project is launched</title><content type='html'>&lt;a href="http://1.bp.blogspot.com/_5vvvyC6SDJw/S7HiiGPlQ9I/AAAAAAAAACA/LGBJqJEbT98/s1600/aa.jpg"&gt;&lt;img style="MARGIN: 0px 10px 10px 0px; WIDTH: 320px; FLOAT: left; HEIGHT: 240px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5454389699141780434" border="0" alt="" src="http://1.bp.blogspot.com/_5vvvyC6SDJw/S7HiiGPlQ9I/AAAAAAAAACA/LGBJqJEbT98/s320/aa.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;div&gt;Feb 26 was another good day of my life when another project was launched officially after the acceptance by the client- a global bank.&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;This project was one of my best work ever.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Project name? well secret..You can book your hotels and flights if you have that Bank's credit card. &lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;There were lots of XML issues in terms of programmability and performance. Well the development is totally in .NET 2.0. It's promising application and adding new dimension to electronic commerce.&lt;/div&gt;&lt;br /&gt;&lt;div&gt;We have earned handsome experience in travel domain :).&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Also, We are working on another similar project but this time with latest tech platform: .Net 4.0 beta 2, WCF etc..Good stuff! Enjoying good time of initiatives. IDE is little complex and sometimes problematic but it's all pleasure to troubleshoot and fun with the latest one.&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;In fact, this project is also ready and we have on beta 1 phase. So end of the day good to go ahead!!&lt;/div&gt; The team is ready to handle the rest of job as I would be moved to some other assignments. &lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;Cheers!!!&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;Sudhir&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6441553613064463233-5959684838128676338?l=sudhironline.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sudhironline.blogspot.com/feeds/5959684838128676338/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sudhironline.blogspot.com/2010/03/smiley-face-after-big-project-is.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6441553613064463233/posts/default/5959684838128676338'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6441553613064463233/posts/default/5959684838128676338'/><link rel='alternate' type='text/html' href='http://sudhironline.blogspot.com/2010/03/smiley-face-after-big-project-is.html' title='Smiley Face After a Big project is launched'/><author><name>Sudhir Dwivedi's .NET Blog</name><uri>http://www.blogger.com/profile/03672675458059523580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='http://2.bp.blogspot.com/_5vvvyC6SDJw/SVfhD8QpsnI/AAAAAAAAAA8/yM02BEUraxg/S220/sudhirindubai.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_5vvvyC6SDJw/S7HiiGPlQ9I/AAAAAAAAACA/LGBJqJEbT98/s72-c/aa.jpg' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6441553613064463233.post-1238509682424448976</id><published>2009-08-26T03:12:00.000-07:00</published><updated>2009-08-28T05:51:21.673-07:00</updated><title type='text'>XML files to C# Classes, Serialization/De-serialization</title><content type='html'>It has been around 42 days since I have written a technical blog. I was given a pretty interesting application to develop in C# 2.0 and ASP.NET. You can call it a really tight timelines when you are given couple of PDF and XML samples of I/O for third party web services and told to develop a services' wrapper and consuming web based application with considerations of thousands of users simultaneously. Application itself hits couple of other legacy systems for data lookups &amp;amp; persistence.&lt;br /&gt;&lt;br /&gt;As it seems, it wasn't a rocket science. Still the manual work/ coding was intensive. I would like to share partial technical intricacies involved in the below sections.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Architectural Guidelines.&lt;/li&gt;&lt;li&gt;Design Considerations.&lt;/li&gt;&lt;li&gt;Creating XML Schema (.XSD) from XML files.&lt;/li&gt;&lt;li&gt;Create C# Class file from XML Schema (.XSD).&lt;/li&gt;&lt;li&gt;Corrections in the generated classes.&lt;/li&gt;&lt;li&gt;Serialzation add-on to the generated classes.&lt;/li&gt;&lt;li&gt;Object Oriented Design Concepts.&lt;/li&gt;&lt;li&gt;Web Service generated proxy issues.&lt;/li&gt;&lt;li&gt;Jungle of Javascript.&lt;/li&gt;&lt;li&gt;Asynchronous Callbacks.&lt;/li&gt;&lt;li&gt;Security Guidelines.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;[I will complete it soon as soon as I get enough time....]&lt;/em&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6441553613064463233-1238509682424448976?l=sudhironline.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sudhironline.blogspot.com/feeds/1238509682424448976/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sudhironline.blogspot.com/2009/08/xml-files-to-c-classes-serializationde.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6441553613064463233/posts/default/1238509682424448976'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6441553613064463233/posts/default/1238509682424448976'/><link rel='alternate' type='text/html' href='http://sudhironline.blogspot.com/2009/08/xml-files-to-c-classes-serializationde.html' title='XML files to C# Classes, Serialization/De-serialization'/><author><name>Sudhir Dwivedi's .NET Blog</name><uri>http://www.blogger.com/profile/03672675458059523580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='http://2.bp.blogspot.com/_5vvvyC6SDJw/SVfhD8QpsnI/AAAAAAAAAA8/yM02BEUraxg/S220/sudhirindubai.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6441553613064463233.post-7200816854936828091</id><published>2009-07-14T07:00:00.000-07:00</published><updated>2009-12-10T00:45:11.560-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Migrating an ASP.NET application from MS SQL Server To MySQL'/><title type='text'>Migrating an ASP.NET application from MS SQL Server To MySQL</title><content type='html'>&lt;p&gt;During last week I was given a short term assignment: Migration of an ASP.NET 3.5 based application from MS SQL Server To MySQL. In fact it was very urgent requirement and one of my managers was little pushed by the client.&lt;br /&gt;&lt;br /&gt;I was wrapping up the Reporting Services project, It was monday evening when he called and shared his worries. Anyways that's too specific and I know you are not interested to listen. Ok so what I had to do: &lt;/p&gt;&lt;ol&gt;&lt;li&gt;MySQL setup/ DB creation and data migration. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;DAL layer changes. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Integration &amp;amp; Testing&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;p&gt;Yes I can accept It's simple job but only if you are kidding ;)&lt;br /&gt;&lt;strong&gt;&lt;br /&gt;Ok what I did:-&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Database's Objects Migration&lt;/strong&gt; &lt;ol&gt;&lt;li&gt;I installed MySQL on my development box. Please remember McAfee is not a friend of yours to install and configure MySQL DB. I disabled McAfee's access protection during the setup. But It is not always a case and otherwise it's not so tough.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;I created a database for the project.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;I downloaded MySQL Migration Toolkit(mysql-gui-tools-5.0-r17-win32.msi) from http://dev.mysql.com/downloads/gui-tools/5.0.html to export objects from MS SQL to MySQL. and I tried the export. But It didn't help enough to achieve the goals. It copied few tables and shown errors for others. I tried to fix with heuristics, I'll point out later.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;I also searched on net for migration tools. I got certain tools but not free of cost. And I wasn't relying on automations and other thing was cost factor, so I decided to apply some tricks.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;I got generated sql script from MS SQL and convert the whole script in MySQL specific syntaxes ;) and I ran those scripts on MySQL.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;…..And my life was 20% happy ;)&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;DAL Migration:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Now I had to change DAL layer to set for MySQL. It was priorily using System.Data.SqlClient in DAL. So I was told to change and optimize it for MySQL. I did following things to achieve the goal. &lt;ol&gt;&lt;li&gt;I got MySql.Data.MySqlClient (Connector/Net 5.2) for my need from MySQL website: http://dev.mysql.com/downloads/connector/net/5.2.html.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;The existing solution's DAL was having a sort of SQL Helper class based on System.Data.SqlClient. Here I replaced this by MySql.Data.MySqlClient.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;I read user manual from here : http://dev.mysql.com/doc/refman/5.1/en/connector-net-ref-mysqlclient.html.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;I found a clue and changed all SqlClient based objects in SQLHelper class just prefixing "My" and indeed after a succeessful build of Data Access Layer, my life seemed cool and I was all set to test the application.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;But grrrrrrrr!! My SPs were not working... errorrrrrrrs. I re-analyzed my lacuna. and again some interesting changes I had to make in order to fix the problem for example I had to replace the sign '@' by '?' while calling a stored procedure from DAL.. and finally I could run the application smoothly :-).&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;strong&gt;What I learnt from this exercise:&lt;/strong&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Don't expect MySQL to have all the same features as MS SQL: If You are using xp_cmdshell in your MSSQL Stored procedures, do not expect MySQL is also able to do the same.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Table Variables are not available in MySQL.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Stored procedure call from DAL in MySQL is prefixed by a question mark i.e. '?' not by a &lt;a href="mailto:"&gt;'@'&lt;/a&gt; as compared to MS SQL Server.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Couple of data types such as MONEY, IMAGE are not supported in MySQL.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;You cannot make an identity(autonumber/autoincrement) field on MySQL table without making it a primary key or certain other column as a primary key. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;MySQL does not support Full Joins.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Error Handling in MySQL is different from MSSQL and If you are using Try/Catch in your T-SQL code supported by CLR, then you are going to face a really hard time. Find alternatives in terms of output parameters etc.&lt;/li&gt;&lt;li&gt;Last but not the least, Please learn basics of MySQL programming before going to take responsibility. Varible declarations, control /looping structures, string handling, system functions are pretty different.&lt;/li&gt;&lt;/ul&gt;Well, this project was not very complex, I wrapped in 2 days. Cool start in MySQL : )&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;I got thanks mail from the manager finally...; )&lt;br /&gt;&lt;br /&gt;Sudhir &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;Updates: 10-dec-2009&lt;/p&gt;&lt;p&gt;MySqlHelper.cs is added: &lt;/p&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;// ===============================================================================&lt;br /&gt;//This class is based on MySQL .NET Provider and similar to MySslClient&lt;br /&gt;// It is revised to meet common needs of an application built in .NET and tested for ASP.NET 2.0&lt;br /&gt;// For more you can send a mail to sudhir@sahpathi.com&lt;br /&gt;// ==============================================================================&lt;br /&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Xml;&lt;br /&gt;using MySql.Data.MySqlClient;&lt;br /&gt;using System.Collections;&lt;br /&gt;　&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// The MySqlHelper class is intended to encapsulate high performance, scalable best practices for&lt;br /&gt;/// common uses of SqlClient&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;public sealed class MySqlHelper&lt;br /&gt;{&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Kalyan (23-01-2007): The DB user name.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;public const string DB_USER_NAME = "";&lt;br /&gt;#region private utility methods &amp;amp; constructors&lt;br /&gt;// Since this class provides only static methods, make the default constructor private to prevent&lt;br /&gt;// instances from being created with "new MySqlHelper()"&lt;br /&gt;private MySqlHelper() { }&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// This method is used to attach array of MySqlParameters to a MySqlCommand.&lt;br /&gt;///&lt;br /&gt;/// This method will assign a value of DbNull to any parameter with a direction of&lt;br /&gt;/// InputOutput and a value of null.&lt;br /&gt;///&lt;br /&gt;/// This behavior will prevent default values from being used, but&lt;br /&gt;/// this will be the less common case than an intended pure output parameter (derived as InputOutput)&lt;br /&gt;/// where the user provided no input value.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="command"&gt;The command to which the parameters will be added&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandParameters"&gt;An array of MySqlParameters to be added to command&lt;/param&gt;&lt;br /&gt;private static void AttachParameters(MySqlCommand command, MySqlParameter[] commandParameters)&lt;br /&gt;{&lt;br /&gt;if (command == null) throw new ArgumentNullException("command");&lt;br /&gt;if (commandParameters != null)&lt;br /&gt;{&lt;br /&gt;foreach (MySqlParameter p in commandParameters)&lt;br /&gt;{&lt;br /&gt;if (p != null)&lt;br /&gt;{&lt;br /&gt;// Check for derived output value with no value assigned&lt;br /&gt;if ((p.Direction == ParameterDirection.InputOutput&lt;br /&gt;p.Direction == ParameterDirection.Input) &amp;amp;&amp;amp;&lt;br /&gt;(p.Value == null))&lt;br /&gt;{&lt;br /&gt;p.Value = DBNull.Value;&lt;br /&gt;}&lt;br /&gt;command.Parameters.Add(p);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// This method assigns dataRow column values to an array of MySqlParameters&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="commandParameters"&gt;Array of MySqlParameters to be assigned values&lt;/param&gt;&lt;br /&gt;/// &lt;param name="dataRow"&gt;The dataRow used to hold the stored procedure's parameter values&lt;/param&gt;&lt;br /&gt;private static void AssignParameterValues(MySqlParameter[] commandParameters, DataRow dataRow)&lt;br /&gt;{&lt;br /&gt;if ((commandParameters == null)  (dataRow == null))&lt;br /&gt;{&lt;br /&gt;// Do nothing if we get no data&lt;br /&gt;return;&lt;br /&gt;}&lt;br /&gt;int i = 0;&lt;br /&gt;// Set the parameters values&lt;br /&gt;foreach (MySqlParameter commandParameter in commandParameters)&lt;br /&gt;{&lt;br /&gt;// Check the parameter name&lt;br /&gt;if (commandParameter.ParameterName == null&lt;br /&gt;commandParameter.ParameterName.Length &lt;= 1)&lt;br /&gt;throw new Exception(&lt;br /&gt;string.Format(&lt;br /&gt;"Please provide a valid parameter name on the parameter #{0}, the ParameterName property has the following value: '{1}'.",&lt;br /&gt;i, commandParameter.ParameterName));&lt;br /&gt;if (dataRow.Table.Columns.IndexOf(commandParameter.ParameterName.Substring(1)) != -1)&lt;br /&gt;commandParameter.Value = dataRow[commandParameter.ParameterName.Substring(1)];&lt;br /&gt;i++;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// This method opens (if necessary) and assigns a connection, transaction, command type and parameters&lt;br /&gt;/// to the provided command&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="command"&gt;The MySqlCommand to be prepared&lt;/param&gt;&lt;br /&gt;/// &lt;param name="connection"&gt;A valid MySqlConnection, on which to execute this command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="transaction"&gt;A valid MySqlTransaction, or 'null'&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandParameters"&gt;An array of MySqlParameters to be associated with the command or 'null' if no parameters are required&lt;/param&gt;&lt;br /&gt;/// &lt;param name="mustCloseConnection"&gt;&lt;c&gt;true&lt;/c&gt; if the connection was opened by the method, otherwose is false.&lt;/param&gt;&lt;br /&gt;private static void PrepareCommand(MySqlCommand command, MySqlConnection connection, MySqlTransaction transaction, CommandType commandType, string commandText, MySqlParameter[] commandParameters, out bool mustCloseConnection)&lt;br /&gt;{&lt;br /&gt;if (command == null) throw new ArgumentNullException("command");&lt;br /&gt;if (commandText == null  commandText.Length == 0) throw new ArgumentNullException("commandText");&lt;br /&gt;// If the provided connection is not open, we will open it&lt;br /&gt;if (connection.State != ConnectionState.Open)&lt;br /&gt;{&lt;br /&gt;mustCloseConnection = true;&lt;br /&gt;connection.Open();&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;mustCloseConnection = false;&lt;br /&gt;}&lt;br /&gt;// Associate the connection with the command&lt;br /&gt;command.Connection = connection;&lt;br /&gt;// Set the command text (stored procedure name or SQL statement)&lt;br /&gt;command.CommandText = DB_USER_NAME + commandText; // Kalyan (23-01-2007): Use Inline Sql at your own risk !!&lt;br /&gt;　&lt;br /&gt;// If we were provided a transaction, assign it&lt;br /&gt;if (transaction != null)&lt;br /&gt;{&lt;br /&gt;if (transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");&lt;br /&gt;command.Transaction = transaction;&lt;br /&gt;}&lt;br /&gt;// Set the command type&lt;br /&gt;command.CommandType = commandType;&lt;br /&gt;// Attach the command parameters if they are provided&lt;br /&gt;if (commandParameters != null)&lt;br /&gt;{&lt;br /&gt;AttachParameters(command, commandParameters);&lt;br /&gt;}&lt;br /&gt;return;&lt;br /&gt;}&lt;br /&gt;#endregion private utility methods &amp;amp; constructors&lt;br /&gt;#region ExecuteNonQuery&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns no resultset and takes no parameters) against the database specified in&lt;br /&gt;/// the connection string&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// int result = ExecuteNonQuery(connString, "PublishOrders");&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="connectionString"&gt;A valid connection string for a MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;An int representing the number of rows affected by the command&lt;/returns&gt;&lt;br /&gt;public static int ExecuteNonQuery(string connectionString, CommandType commandType, string commandText)&lt;br /&gt;{&lt;br /&gt;// Pass through the call providing null for the set of MySqlParameters&lt;br /&gt;return ExecuteNonQuery(connectionString, commandType, commandText, (MySqlParameter[])null);&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns no resultset) against the database specified in the connection string&lt;br /&gt;/// using the provided parameters&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// int result = ExecuteNonQuery(connString, "PublishOrders", new MySqlParameter("@prodid", 24));&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="connectionString"&gt;A valid connection string for a MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandParameters"&gt;An array of SqlParamters used to execute the command&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;An int representing the number of rows affected by the command&lt;/returns&gt;&lt;br /&gt;public static int ExecuteNonQuery(string connectionString, CommandType commandType, string commandText, params MySqlParameter[] commandParameters)&lt;br /&gt;{&lt;br /&gt;if (connectionString == null  connectionString.Length == 0) throw new ArgumentNullException("connectionString");&lt;br /&gt;// Create &amp;amp; open a MySqlConnection, and dispose of it after we are done&lt;br /&gt;using (MySqlConnection connection = new MySqlConnection(connectionString))&lt;br /&gt;{&lt;br /&gt;connection.Open();&lt;br /&gt;// Call the overload that takes a connection in place of the connection string&lt;br /&gt;return ExecuteNonQuery(connection, commandType, commandText, commandParameters);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns no resultset and takes no parameters) against the provided MySqlConnection.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// int result = ExecuteNonQuery(conn, "PublishOrders");&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="connection"&gt;A valid MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;An int representing the number of rows affected by the command&lt;/returns&gt;&lt;br /&gt;public static int ExecuteNonQuery(MySqlConnection connection, CommandType commandType, string commandText)&lt;br /&gt;{&lt;br /&gt;// Pass through the call providing null for the set of MySqlParameters&lt;br /&gt;return ExecuteNonQuery(connection, commandType, commandText, (MySqlParameter[])null);&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns no resultset) against the specified MySqlConnection&lt;br /&gt;/// using the provided parameters.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// int result = ExecuteNonQuery(conn, "PublishOrders", new MySqlParameter("@prodid", 24));&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="connection"&gt;A valid MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandParameters"&gt;An array of SqlParamters used to execute the command&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;An int representing the number of rows affected by the command&lt;/returns&gt;&lt;br /&gt;public static int ExecuteNonQuery(MySqlConnection connection, CommandType commandType, string commandText, params MySqlParameter[] commandParameters)&lt;br /&gt;{&lt;br /&gt;if (connection == null) throw new ArgumentNullException("connection");&lt;br /&gt;// Create a command and prepare it for execution&lt;br /&gt;MySqlCommand cmd = new MySqlCommand();&lt;br /&gt;bool mustCloseConnection = false;&lt;br /&gt;PrepareCommand(cmd, connection, (MySqlTransaction)null, commandType, commandText, commandParameters, out mustCloseConnection);&lt;br /&gt;// Finally, execute the command&lt;br /&gt;int retval = cmd.ExecuteNonQuery();&lt;br /&gt;// Detach the MySqlParameters from the command object, so they can be used again&lt;br /&gt;cmd.Parameters.Clear();&lt;br /&gt;if (mustCloseConnection)&lt;br /&gt;connection.Close();&lt;br /&gt;return retval;&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns no resultset and takes no parameters) against the provided MySqlTransaction.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// int result = ExecuteNonQuery(trans, "PublishOrders");&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="transaction"&gt;A valid MySqlTransaction&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;An int representing the number of rows affected by the command&lt;/returns&gt;&lt;br /&gt;public static int ExecuteNonQuery(MySqlTransaction transaction, CommandType commandType, string commandText)&lt;br /&gt;{&lt;br /&gt;// Pass through the call providing null for the set of MySqlParameters&lt;br /&gt;return ExecuteNonQuery(transaction, commandType, commandText, (MySqlParameter[])null);&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns no resultset) against the specified MySqlTransaction&lt;br /&gt;/// using the provided parameters.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// int result = ExecuteNonQuery(trans, "GetOrders", new MySqlParameter("@prodid", 24));&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="transaction"&gt;A valid MySqlTransaction&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandParameters"&gt;An array of SqlParamters used to execute the command&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;An int representing the number of rows affected by the command&lt;/returns&gt;&lt;br /&gt;public static int ExecuteNonQuery(MySqlTransaction transaction, CommandType commandType, string commandText, params MySqlParameter[] commandParameters)&lt;br /&gt;{&lt;br /&gt;if (transaction == null) throw new ArgumentNullException("transaction");&lt;br /&gt;if (transaction != null &amp;amp;&amp;amp; transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");&lt;br /&gt;// Create a command and prepare it for execution&lt;br /&gt;MySqlCommand cmd = new MySqlCommand();&lt;br /&gt;bool mustCloseConnection = false;&lt;br /&gt;PrepareCommand(cmd, transaction.Connection, transaction, commandType, commandText, commandParameters, out mustCloseConnection);&lt;br /&gt;// Finally, execute the command&lt;br /&gt;int retval = cmd.ExecuteNonQuery();&lt;br /&gt;// Detach the MySqlParameters from the command object, so they can be used again&lt;br /&gt;cmd.Parameters.Clear();&lt;br /&gt;return retval;&lt;br /&gt;}&lt;br /&gt;#endregion ExecuteNonQuery&lt;br /&gt;#region ExecuteDataset&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns a resultset and takes no parameters) against the database specified in&lt;br /&gt;/// the connection string.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// DataSet ds = ExecuteDataset(connString, "GetOrders");&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="connectionString"&gt;A valid connection string for a MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;A dataset containing the resultset generated by the command&lt;/returns&gt;&lt;br /&gt;public static DataSet ExecuteDataset(string connectionString, CommandType commandType, string commandText)&lt;br /&gt;{&lt;br /&gt;// Pass through the call providing null for the set of MySqlParameters&lt;br /&gt;return ExecuteDataset(connectionString, commandType, commandText, (MySqlParameter[])null);&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns a resultset) against the database specified in the connection string&lt;br /&gt;/// using the provided parameters.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// DataSet ds = ExecuteDataset(connString, "GetOrders", new MySqlParameter("@prodid", 24));&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="connectionString"&gt;A valid connection string for a MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandParameters"&gt;An array of SqlParamters used to execute the command&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;A dataset containing the resultset generated by the command&lt;/returns&gt;&lt;br /&gt;public static DataSet ExecuteDataset(string connectionString, CommandType commandType, string commandText, params MySqlParameter[] commandParameters)&lt;br /&gt;{&lt;br /&gt;if (connectionString == null  connectionString.Length == 0) throw new ArgumentNullException("connectionString");&lt;br /&gt;// Create &amp;amp; open a MySqlConnection, and dispose of it after we are done&lt;br /&gt;using (MySqlConnection connection = new MySqlConnection(connectionString))&lt;br /&gt;{&lt;br /&gt;connection.Open();&lt;br /&gt;// Call the overload that takes a connection in place of the connection string&lt;br /&gt;return ExecuteDataset(connection, commandType, commandText, commandParameters);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns a resultset and takes no parameters) against the provided MySqlConnection.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// DataSet ds = ExecuteDataset(conn, "GetOrders");&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="connection"&gt;A valid MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;A dataset containing the resultset generated by the command&lt;/returns&gt;&lt;br /&gt;public static DataSet ExecuteDataset(MySqlConnection connection, CommandType commandType, string commandText)&lt;br /&gt;{&lt;br /&gt;// Pass through the call providing null for the set of MySqlParameters&lt;br /&gt;return ExecuteDataset(connection, commandType, commandText, (MySqlParameter[])null);&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns a resultset) against the specified MySqlConnection&lt;br /&gt;/// using the provided parameters.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// DataSet ds = ExecuteDataset(conn, "GetOrders", new MySqlParameter("@prodid", 24));&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="connection"&gt;A valid MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandParameters"&gt;An array of SqlParamters used to execute the command&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;A dataset containing the resultset generated by the command&lt;/returns&gt;&lt;br /&gt;public static DataSet ExecuteDataset(MySqlConnection connection, CommandType commandType, string commandText, params MySqlParameter[] commandParameters)&lt;br /&gt;{&lt;br /&gt;if (connection == null) throw new ArgumentNullException("connection");&lt;br /&gt;// Create a command and prepare it for execution&lt;br /&gt;MySqlCommand cmd = new MySqlCommand();&lt;br /&gt;bool mustCloseConnection = false;&lt;br /&gt;PrepareCommand(cmd, connection, (MySqlTransaction)null, commandType, commandText, commandParameters, out mustCloseConnection);&lt;br /&gt;// Create the DataAdapter &amp;amp; DataSet&lt;br /&gt;using (MySqlDataAdapter da = new MySqlDataAdapter(cmd))&lt;br /&gt;{&lt;br /&gt;DataSet ds = new DataSet();&lt;br /&gt;// Fill the DataSet using default values for DataTable names, etc&lt;br /&gt;da.Fill(ds);&lt;br /&gt;// Detach the MySqlParameters from the command object, so they can be used again&lt;br /&gt;cmd.Parameters.Clear();&lt;br /&gt;if (mustCloseConnection)&lt;br /&gt;connection.Close();&lt;br /&gt;// Return the dataset&lt;br /&gt;return ds;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns a resultset and takes no parameters) against the provided MySqlTransaction.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// DataSet ds = ExecuteDataset(trans, "GetOrders");&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="transaction"&gt;A valid MySqlTransaction&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;A dataset containing the resultset generated by the command&lt;/returns&gt;&lt;br /&gt;public static DataSet ExecuteDataset(MySqlTransaction transaction, CommandType commandType, string commandText)&lt;br /&gt;{&lt;br /&gt;// Pass through the call providing null for the set of MySqlParameters&lt;br /&gt;return ExecuteDataset(transaction, commandType, commandText, (MySqlParameter[])null);&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns a resultset) against the specified MySqlTransaction&lt;br /&gt;/// using the provided parameters.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// DataSet ds = ExecuteDataset(trans, "GetOrders", new MySqlParameter("@prodid", 24));&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="transaction"&gt;A valid MySqlTransaction&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandParameters"&gt;An array of SqlParamters used to execute the command&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;A dataset containing the resultset generated by the command&lt;/returns&gt;&lt;br /&gt;public static DataSet ExecuteDataset(MySqlTransaction transaction, CommandType commandType, string commandText, params MySqlParameter[] commandParameters)&lt;br /&gt;{&lt;br /&gt;if (transaction == null) throw new ArgumentNullException("transaction");&lt;br /&gt;if (transaction != null &amp;amp;&amp;amp; transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");&lt;br /&gt;// Create a command and prepare it for execution&lt;br /&gt;MySqlCommand cmd = new MySqlCommand();&lt;br /&gt;bool mustCloseConnection = false;&lt;br /&gt;PrepareCommand(cmd, transaction.Connection, transaction, commandType, commandText, commandParameters, out mustCloseConnection);&lt;br /&gt;// Create the DataAdapter &amp;amp; DataSet&lt;br /&gt;using (MySqlDataAdapter da = new MySqlDataAdapter(cmd))&lt;br /&gt;{&lt;br /&gt;DataSet ds = new DataSet();&lt;br /&gt;// Fill the DataSet using default values for DataTable names, etc&lt;br /&gt;da.Fill(ds);&lt;br /&gt;// Detach the MySqlParameters from the command object, so they can be used again&lt;br /&gt;cmd.Parameters.Clear();&lt;br /&gt;// Return the dataset&lt;br /&gt;return ds;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;#endregion ExecuteDataset&lt;br /&gt;#region ExecuteReader&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// This enum is used to indicate whether the connection was provided by the caller, or created by MySqlHelper, so that&lt;br /&gt;/// we can set the appropriate CommandBehavior when calling ExecuteReader()&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;private enum MySqlConnectionOwnership&lt;br /&gt;{&lt;br /&gt;/// &lt;summary&gt;Connection is owned and managed by MySqlHelper&lt;/summary&gt;&lt;br /&gt;Internal,&lt;br /&gt;/// &lt;summary&gt;Connection is owned and managed by the caller&lt;/summary&gt;&lt;br /&gt;External&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Create and prepare a MySqlCommand, and call ExecuteReader with the appropriate CommandBehavior.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// If we created and opened the connection, we want the connection to be closed when the DataReader is closed.&lt;br /&gt;///&lt;br /&gt;/// If the caller provided the connection, we want to leave it to them to manage.&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="connection"&gt;A valid MySqlConnection, on which to execute this command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="transaction"&gt;A valid MySqlTransaction, or 'null'&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandParameters"&gt;An array of MySqlParameters to be associated with the command or 'null' if no parameters are required&lt;/param&gt;&lt;br /&gt;/// &lt;param name="connectionOwnership"&gt;Indicates whether the connection parameter was provided by the caller, or created by MySqlHelper&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;MySqlDataReader containing the results of the command&lt;/returns&gt;&lt;br /&gt;private static MySqlDataReader ExecuteReader(MySqlConnection connection, MySqlTransaction transaction, CommandType commandType, string commandText, MySqlParameter[] commandParameters, MySqlConnectionOwnership connectionOwnership)&lt;br /&gt;{&lt;br /&gt;if (connection == null) throw new ArgumentNullException("connection");&lt;br /&gt;bool mustCloseConnection = false;&lt;br /&gt;// Create a command and prepare it for execution&lt;br /&gt;MySqlCommand cmd = new MySqlCommand();&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;PrepareCommand(cmd, connection, transaction, commandType, commandText, commandParameters, out mustCloseConnection);&lt;br /&gt;// Create a reader&lt;br /&gt;MySqlDataReader dataReader;&lt;br /&gt;// Call ExecuteReader with the appropriate CommandBehavior&lt;br /&gt;if (connectionOwnership == MySqlConnectionOwnership.External)&lt;br /&gt;{&lt;br /&gt;dataReader = cmd.ExecuteReader();&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;dataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);&lt;br /&gt;}&lt;br /&gt;// Detach the MySqlParameters from the command object, so they can be used again.&lt;br /&gt;// HACK: There is a problem here, the output parameter values are fletched&lt;br /&gt;// when the reader is closed, so if the parameters are detached from the command&lt;br /&gt;// then the SqlReader can´t set its values.&lt;br /&gt;// When this happen, the parameters can´t be used again in other command.&lt;br /&gt;bool canClear = true;&lt;br /&gt;foreach (MySqlParameter commandParameter in cmd.Parameters)&lt;br /&gt;{&lt;br /&gt;if (commandParameter.Direction != ParameterDirection.Input)&lt;br /&gt;canClear = false;&lt;br /&gt;}&lt;br /&gt;if (canClear)&lt;br /&gt;{&lt;br /&gt;cmd.Parameters.Clear();&lt;br /&gt;}&lt;br /&gt;return dataReader;&lt;br /&gt;}&lt;br /&gt;catch&lt;br /&gt;{&lt;br /&gt;if (mustCloseConnection)&lt;br /&gt;connection.Close();&lt;br /&gt;throw;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns a resultset and takes no parameters) against the database specified in&lt;br /&gt;/// the connection string.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// MySqlDataReader dr = ExecuteReader(connString, "GetOrders");&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="connectionString"&gt;A valid connection string for a MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;A MySqlDataReader containing the resultset generated by the command&lt;/returns&gt;&lt;br /&gt;public static MySqlDataReader ExecuteReader(string connectionString, CommandType commandType, string commandText)&lt;br /&gt;{&lt;br /&gt;// Pass through the call providing null for the set of MySqlParameters&lt;br /&gt;return ExecuteReader(connectionString, commandType, commandText, (MySqlParameter[])null);&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns a resultset) against the database specified in the connection string&lt;br /&gt;/// using the provided parameters.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// MySqlDataReader dr = ExecuteReader(connString, "GetOrders", new MySqlParameter("@prodid", 24));&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="connectionString"&gt;A valid connection string for a MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandParameters"&gt;An array of SqlParamters used to execute the command&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;A MySqlDataReader containing the resultset generated by the command&lt;/returns&gt;&lt;br /&gt;public static MySqlDataReader ExecuteReader(string connectionString, CommandType commandType, string commandText, params MySqlParameter[] commandParameters)&lt;br /&gt;{&lt;br /&gt;if (connectionString == null  connectionString.Length == 0) throw new ArgumentNullException("connectionString");&lt;br /&gt;MySqlConnection connection = null;&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;connection = new MySqlConnection(connectionString);&lt;br /&gt;connection.Open();&lt;br /&gt;// Call the private overload that takes an internally owned connection in place of the connection string&lt;br /&gt;return ExecuteReader(connection, null, commandType, commandText, commandParameters, MySqlConnectionOwnership.Internal);&lt;br /&gt;}&lt;br /&gt;catch&lt;br /&gt;{&lt;br /&gt;// If we fail to return the SqlDatReader, we need to close the connection ourselves&lt;br /&gt;if (connection != null) connection.Close();&lt;br /&gt;throw;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns a resultset and takes no parameters) against the provided MySqlConnection.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// MySqlDataReader dr = ExecuteReader(conn, "GetOrders");&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="connection"&gt;A valid MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;A MySqlDataReader containing the resultset generated by the command&lt;/returns&gt;&lt;br /&gt;public static MySqlDataReader ExecuteReader(MySqlConnection connection, CommandType commandType, string commandText)&lt;br /&gt;{&lt;br /&gt;// Pass through the call providing null for the set of MySqlParameters&lt;br /&gt;return ExecuteReader(connection, commandType, commandText, (MySqlParameter[])null);&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns a resultset) against the specified MySqlConnection&lt;br /&gt;/// using the provided parameters.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// MySqlDataReader dr = ExecuteReader(conn, "GetOrders", new MySqlParameter("@prodid", 24));&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="connection"&gt;A valid MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandParameters"&gt;An array of SqlParamters used to execute the command&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;A MySqlDataReader containing the resultset generated by the command&lt;/returns&gt;&lt;br /&gt;public static MySqlDataReader ExecuteReader(MySqlConnection connection, CommandType commandType, string commandText, params MySqlParameter[] commandParameters)&lt;br /&gt;{&lt;br /&gt;// Pass through the call to the private overload using a null transaction value and an externally owned connection&lt;br /&gt;return ExecuteReader(connection, (MySqlTransaction)null, commandType, commandText, commandParameters, MySqlConnectionOwnership.External);&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns a resultset and takes no parameters) against the provided MySqlTransaction.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// MySqlDataReader dr = ExecuteReader(trans, "GetOrders");&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="transaction"&gt;A valid MySqlTransaction&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;A MySqlDataReader containing the resultset generated by the command&lt;/returns&gt;&lt;br /&gt;public static MySqlDataReader ExecuteReader(MySqlTransaction transaction, CommandType commandType, string commandText)&lt;br /&gt;{&lt;br /&gt;// Pass through the call providing null for the set of MySqlParameters&lt;br /&gt;return ExecuteReader(transaction, commandType, commandText, (MySqlParameter[])null);&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns a resultset) against the specified MySqlTransaction&lt;br /&gt;/// using the provided parameters.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// MySqlDataReader dr = ExecuteReader(trans, "GetOrders", new MySqlParameter("@prodid", 24));&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="transaction"&gt;A valid MySqlTransaction&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandParameters"&gt;An array of SqlParamters used to execute the command&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;A MySqlDataReader containing the resultset generated by the command&lt;/returns&gt;&lt;br /&gt;public static MySqlDataReader ExecuteReader(MySqlTransaction transaction, CommandType commandType, string commandText, params MySqlParameter[] commandParameters)&lt;br /&gt;{&lt;br /&gt;if (transaction == null) throw new ArgumentNullException("transaction");&lt;br /&gt;if (transaction != null &amp;amp;&amp;amp; transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");&lt;br /&gt;// Pass through to private overload, indicating that the connection is owned by the caller&lt;br /&gt;return ExecuteReader(transaction.Connection, transaction, commandType, commandText, commandParameters, MySqlConnectionOwnership.External);&lt;br /&gt;}&lt;br /&gt;#endregion ExecuteReader&lt;br /&gt;#region ExecuteScalar&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns a 1x1 resultset and takes no parameters) against the database specified in&lt;br /&gt;/// the connection string.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// int orderCount = (int)ExecuteScalar(connString, "GetOrderCount");&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="connectionString"&gt;A valid connection string for a MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;An object containing the value in the 1x1 resultset generated by the command&lt;/returns&gt;&lt;br /&gt;public static object ExecuteScalar(string connectionString, CommandType commandType, string commandText)&lt;br /&gt;{&lt;br /&gt;// Pass through the call providing null for the set of MySqlParameters&lt;br /&gt;return ExecuteScalar(connectionString, commandType, commandText, (MySqlParameter[])null);&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns a 1x1 resultset) against the database specified in the connection string&lt;br /&gt;/// using the provided parameters.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// int orderCount = (int)ExecuteScalar(connString, "GetOrderCount", new MySqlParameter("@prodid", 24));&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="connectionString"&gt;A valid connection string for a MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandParameters"&gt;An array of SqlParamters used to execute the command&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;An object containing the value in the 1x1 resultset generated by the command&lt;/returns&gt;&lt;br /&gt;public static object ExecuteScalar(string connectionString, CommandType commandType, string commandText, params MySqlParameter[] commandParameters)&lt;br /&gt;{&lt;br /&gt;if (connectionString == null  connectionString.Length == 0) throw new ArgumentNullException("connectionString");&lt;br /&gt;// Create &amp;amp; open a MySqlConnection, and dispose of it after we are done&lt;br /&gt;using (MySqlConnection connection = new MySqlConnection(connectionString))&lt;br /&gt;{&lt;br /&gt;connection.Open();&lt;br /&gt;// Call the overload that takes a connection in place of the connection string&lt;br /&gt;return ExecuteScalar(connection, commandType, commandText, commandParameters);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns a 1x1 resultset and takes no parameters) against the provided MySqlConnection.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// int orderCount = (int)ExecuteScalar(conn, "GetOrderCount");&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="connection"&gt;A valid MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;An object containing the value in the 1x1 resultset generated by the command&lt;/returns&gt;&lt;br /&gt;public static object ExecuteScalar(MySqlConnection connection, CommandType commandType, string commandText)&lt;br /&gt;{&lt;br /&gt;// Pass through the call providing null for the set of MySqlParameters&lt;br /&gt;return ExecuteScalar(connection, commandType, commandText, (MySqlParameter[])null);&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns a 1x1 resultset) against the specified MySqlConnection&lt;br /&gt;/// using the provided parameters.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// int orderCount = (int)ExecuteScalar(conn, "GetOrderCount", new MySqlParameter("@prodid", 24));&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="connection"&gt;A valid MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandParameters"&gt;An array of SqlParamters used to execute the command&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;An object containing the value in the 1x1 resultset generated by the command&lt;/returns&gt;&lt;br /&gt;public static object ExecuteScalar(MySqlConnection connection, CommandType commandType, string commandText, params MySqlParameter[] commandParameters)&lt;br /&gt;{&lt;br /&gt;if (connection == null) throw new ArgumentNullException("connection");&lt;br /&gt;// Create a command and prepare it for execution&lt;br /&gt;MySqlCommand cmd = new MySqlCommand();&lt;br /&gt;bool mustCloseConnection = false;&lt;br /&gt;PrepareCommand(cmd, connection, (MySqlTransaction)null, commandType, commandText, commandParameters, out mustCloseConnection);&lt;br /&gt;// Execute the command &amp;amp; return the results&lt;br /&gt;object retval = cmd.ExecuteScalar();&lt;br /&gt;// Detach the MySqlParameters from the command object, so they can be used again&lt;br /&gt;cmd.Parameters.Clear();&lt;br /&gt;if (mustCloseConnection)&lt;br /&gt;connection.Close();&lt;br /&gt;return retval;&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns a 1x1 resultset and takes no parameters) against the provided MySqlTransaction.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// int orderCount = (int)ExecuteScalar(trans, "GetOrderCount");&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="transaction"&gt;A valid MySqlTransaction&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;An object containing the value in the 1x1 resultset generated by the command&lt;/returns&gt;&lt;br /&gt;public static object ExecuteScalar(MySqlTransaction transaction, CommandType commandType, string commandText)&lt;br /&gt;{&lt;br /&gt;// Pass through the call providing null for the set of MySqlParameters&lt;br /&gt;return ExecuteScalar(transaction, commandType, commandText, (MySqlParameter[])null);&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns a 1x1 resultset) against the specified MySqlTransaction&lt;br /&gt;/// using the provided parameters.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// int orderCount = (int)ExecuteScalar(trans, "GetOrderCount", new MySqlParameter("@prodid", 24));&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="transaction"&gt;A valid MySqlTransaction&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandParameters"&gt;An array of SqlParamters used to execute the command&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;An object containing the value in the 1x1 resultset generated by the command&lt;/returns&gt;&lt;br /&gt;public static object ExecuteScalar(MySqlTransaction transaction, CommandType commandType, string commandText, params MySqlParameter[] commandParameters)&lt;br /&gt;{&lt;br /&gt;if (transaction == null) throw new ArgumentNullException("transaction");&lt;br /&gt;if (transaction != null &amp;amp;&amp;amp; transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");&lt;br /&gt;// Create a command and prepare it for execution&lt;br /&gt;MySqlCommand cmd = new MySqlCommand();&lt;br /&gt;bool mustCloseConnection = false;&lt;br /&gt;PrepareCommand(cmd, transaction.Connection, transaction, commandType, commandText, commandParameters, out mustCloseConnection);&lt;br /&gt;// Execute the command &amp;amp; return the results&lt;br /&gt;object retval = cmd.ExecuteScalar();&lt;br /&gt;// Detach the MySqlParameters from the command object, so they can be used again&lt;br /&gt;cmd.Parameters.Clear();&lt;br /&gt;return retval;&lt;br /&gt;}&lt;br /&gt;#endregion ExecuteScalar&lt;br /&gt;　&lt;br /&gt;#region FillDataset&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns a resultset and takes no parameters) against the database specified in&lt;br /&gt;/// the connection string.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// FillDataset(connString, "GetOrders", ds, new string[] {"orders"});&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="connectionString"&gt;A valid connection string for a MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="dataSet"&gt;A dataset wich will contain the resultset generated by the command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="tableNames"&gt;This array will be used to create table mappings allowing the DataTables to be referenced&lt;br /&gt;/// by a user defined name (probably the actual table name)&lt;/param&gt;&lt;br /&gt;public static void FillDataset(string connectionString, CommandType commandType, string commandText, DataSet dataSet, string[] tableNames)&lt;br /&gt;{&lt;br /&gt;if (connectionString == null  connectionString.Length == 0) throw new ArgumentNullException("connectionString");&lt;br /&gt;if (dataSet == null) throw new ArgumentNullException("dataSet");&lt;br /&gt;// Create &amp;amp; open a MySqlConnection, and dispose of it after we are done&lt;br /&gt;using (MySqlConnection connection = new MySqlConnection(connectionString))&lt;br /&gt;{&lt;br /&gt;connection.Open();&lt;br /&gt;// Call the overload that takes a connection in place of the connection string&lt;br /&gt;FillDataset(connection, commandType, commandText, dataSet, tableNames);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns a resultset) against the database specified in the connection string&lt;br /&gt;/// using the provided parameters.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// FillDataset(connString, "GetOrders", ds, new string[] {"orders"}, new MySqlParameter("@prodid", 24));&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="connectionString"&gt;A valid connection string for a MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandParameters"&gt;An array of SqlParamters used to execute the command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="dataSet"&gt;A dataset wich will contain the resultset generated by the command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="tableNames"&gt;This array will be used to create table mappings allowing the DataTables to be referenced&lt;br /&gt;/// by a user defined name (probably the actual table name)&lt;br /&gt;/// &lt;/param&gt;&lt;br /&gt;public static void FillDataset(string connectionString, CommandType commandType,&lt;br /&gt;string commandText, DataSet dataSet, string[] tableNames,&lt;br /&gt;params MySqlParameter[] commandParameters)&lt;br /&gt;{&lt;br /&gt;if (connectionString == null  connectionString.Length == 0) throw new ArgumentNullException("connectionString");&lt;br /&gt;if (dataSet == null) throw new ArgumentNullException("dataSet");&lt;br /&gt;// Create &amp;amp; open a MySqlConnection, and dispose of it after we are done&lt;br /&gt;using (MySqlConnection connection = new MySqlConnection(connectionString))&lt;br /&gt;{&lt;br /&gt;connection.Open();&lt;br /&gt;// Call the overload that takes a connection in place of the connection string&lt;br /&gt;FillDataset(connection, commandType, commandText, dataSet, tableNames, commandParameters);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns a resultset and takes no parameters) against the provided MySqlConnection.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// FillDataset(conn, "GetOrders", ds, new string[] {"orders"});&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="connection"&gt;A valid MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="dataSet"&gt;A dataset wich will contain the resultset generated by the command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="tableNames"&gt;This array will be used to create table mappings allowing the DataTables to be referenced&lt;br /&gt;/// by a user defined name (probably the actual table name)&lt;br /&gt;/// &lt;/param&gt;&lt;br /&gt;public static void FillDataset(MySqlConnection connection, CommandType commandType,&lt;br /&gt;string commandText, DataSet dataSet, string[] tableNames)&lt;br /&gt;{&lt;br /&gt;FillDataset(connection, commandType, commandText, dataSet, tableNames, null);&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns a resultset) against the specified MySqlConnection&lt;br /&gt;/// using the provided parameters.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// FillDataset(conn, "GetOrders", ds, new string[] {"orders"}, new MySqlParameter("@prodid", 24));&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="connection"&gt;A valid MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="dataSet"&gt;A dataset wich will contain the resultset generated by the command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="tableNames"&gt;This array will be used to create table mappings allowing the DataTables to be referenced&lt;br /&gt;/// by a user defined name (probably the actual table name)&lt;br /&gt;/// &lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandParameters"&gt;An array of SqlParamters used to execute the command&lt;/param&gt;&lt;br /&gt;public static void FillDataset(MySqlConnection connection, CommandType commandType,&lt;br /&gt;string commandText, DataSet dataSet, string[] tableNames,&lt;br /&gt;params MySqlParameter[] commandParameters)&lt;br /&gt;{&lt;br /&gt;FillDataset(connection, null, commandType, commandText, dataSet, tableNames, commandParameters);&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns a resultset and takes no parameters) against the provided MySqlTransaction.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// FillDataset(trans, "GetOrders", ds, new string[] {"orders"});&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="transaction"&gt;A valid MySqlTransaction&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="dataSet"&gt;A dataset wich will contain the resultset generated by the command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="tableNames"&gt;This array will be used to create table mappings allowing the DataTables to be referenced&lt;br /&gt;/// by a user defined name (probably the actual table name)&lt;br /&gt;/// &lt;/param&gt;&lt;br /&gt;public static void FillDataset(MySqlTransaction transaction, CommandType commandType,&lt;br /&gt;string commandText,&lt;br /&gt;DataSet dataSet, string[] tableNames)&lt;br /&gt;{&lt;br /&gt;FillDataset(transaction, commandType, commandText, dataSet, tableNames, null);&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a MySqlCommand (that returns a resultset) against the specified MySqlTransaction&lt;br /&gt;/// using the provided parameters.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// FillDataset(trans, "GetOrders", ds, new string[] {"orders"}, new MySqlParameter("@prodid", 24));&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="transaction"&gt;A valid MySqlTransaction&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="dataSet"&gt;A dataset wich will contain the resultset generated by the command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="tableNames"&gt;This array will be used to create table mappings allowing the DataTables to be referenced&lt;br /&gt;/// by a user defined name (probably the actual table name)&lt;br /&gt;/// &lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandParameters"&gt;An array of SqlParamters used to execute the command&lt;/param&gt;&lt;br /&gt;public static void FillDataset(MySqlTransaction transaction, CommandType commandType,&lt;br /&gt;string commandText, DataSet dataSet, string[] tableNames,&lt;br /&gt;params MySqlParameter[] commandParameters)&lt;br /&gt;{&lt;br /&gt;FillDataset(transaction.Connection, transaction, commandType, commandText, dataSet, tableNames, commandParameters);&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Private helper method that execute a MySqlCommand (that returns a resultset) against the specified MySqlTransaction and MySqlConnection&lt;br /&gt;/// using the provided parameters.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// FillDataset(conn, trans, "GetOrders", ds, new string[] {"orders"}, new MySqlParameter("@prodid", 24));&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="connection"&gt;A valid MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="transaction"&gt;A valid MySqlTransaction&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandType"&gt;The CommandType (stored procedure, text, etc.)&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="dataSet"&gt;A dataset wich will contain the resultset generated by the command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="tableNames"&gt;This array will be used to create table mappings allowing the DataTables to be referenced&lt;br /&gt;/// by a user defined name (probably the actual table name)&lt;br /&gt;/// &lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandParameters"&gt;An array of SqlParamters used to execute the command&lt;/param&gt;&lt;br /&gt;private static void FillDataset(MySqlConnection connection, MySqlTransaction transaction, CommandType commandType,&lt;br /&gt;string commandText, DataSet dataSet, string[] tableNames,&lt;br /&gt;params MySqlParameter[] commandParameters)&lt;br /&gt;{&lt;br /&gt;if (connection == null) throw new ArgumentNullException("connection");&lt;br /&gt;if (dataSet == null) throw new ArgumentNullException("dataSet");&lt;br /&gt;// Create a command and prepare it for execution&lt;br /&gt;MySqlCommand command = new MySqlCommand();&lt;br /&gt;bool mustCloseConnection = false;&lt;br /&gt;PrepareCommand(command, connection, transaction, commandType, commandText, commandParameters, out mustCloseConnection);&lt;br /&gt;// Create the DataAdapter &amp;amp; DataSet&lt;br /&gt;using (MySqlDataAdapter dataAdapter = new MySqlDataAdapter(command))&lt;br /&gt;{&lt;br /&gt;// Add the table mappings specified by the user&lt;br /&gt;if (tableNames != null &amp;amp;&amp;amp; tableNames.Length &gt; 0)&lt;br /&gt;{&lt;br /&gt;string tableName = "Table";&lt;br /&gt;for (int index = 0; index &lt; tableNames.Length; index++)&lt;br /&gt;{&lt;br /&gt;if (tableNames[index] == null  tableNames[index].Length == 0) throw new ArgumentException("The tableNames parameter must contain a list of tables, a value was provided as null or empty string.", "tableNames");&lt;br /&gt;dataAdapter.TableMappings.Add(tableName, tableNames[index]);&lt;br /&gt;tableName += (index + 1).ToString();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;// Fill the DataSet using default values for DataTable names, etc&lt;br /&gt;dataAdapter.Fill(dataSet);&lt;br /&gt;// Detach the MySqlParameters from the command object, so they can be used again&lt;br /&gt;command.Parameters.Clear();&lt;br /&gt;}&lt;br /&gt;if (mustCloseConnection)&lt;br /&gt;connection.Close();&lt;br /&gt;}&lt;br /&gt;#endregion&lt;br /&gt;#region UpdateDataset&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Executes the respective command for each inserted, updated, or deleted row in the DataSet.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// UpdateDataset(conn, insertCommand, deleteCommand, updateCommand, dataSet, "Order");&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="insertCommand"&gt;A valid transact-SQL statement or stored procedure to insert new records into the data source&lt;/param&gt;&lt;br /&gt;/// &lt;param name="deleteCommand"&gt;A valid transact-SQL statement or stored procedure to delete records from the data source&lt;/param&gt;&lt;br /&gt;/// &lt;param name="updateCommand"&gt;A valid transact-SQL statement or stored procedure used to update records in the data source&lt;/param&gt;&lt;br /&gt;/// &lt;param name="dataSet"&gt;The DataSet used to update the data source&lt;/param&gt;&lt;br /&gt;/// &lt;param name="tableName"&gt;The DataTable used to update the data source.&lt;/param&gt;&lt;br /&gt;public static void UpdateDataset(MySqlCommand insertCommand, MySqlCommand deleteCommand, MySqlCommand updateCommand, DataSet dataSet, string tableName)&lt;br /&gt;{&lt;br /&gt;if (insertCommand == null) throw new ArgumentNullException("insertCommand");&lt;br /&gt;if (deleteCommand == null) throw new ArgumentNullException("deleteCommand");&lt;br /&gt;if (updateCommand == null) throw new ArgumentNullException("updateCommand");&lt;br /&gt;if (tableName == null  tableName.Length == 0) throw new ArgumentNullException("tableName");&lt;br /&gt;// Create a MySqlDataAdapter, and dispose of it after we are done&lt;br /&gt;using (MySqlDataAdapter dataAdapter = new MySqlDataAdapter())&lt;br /&gt;{&lt;br /&gt;// Set the data adapter commands&lt;br /&gt;dataAdapter.UpdateCommand = updateCommand;&lt;br /&gt;dataAdapter.InsertCommand = insertCommand;&lt;br /&gt;dataAdapter.DeleteCommand = deleteCommand;&lt;br /&gt;// Update the dataset changes in the data source&lt;br /&gt;dataAdapter.Update(dataSet, tableName);&lt;br /&gt;// Commit all the changes made to the DataSet&lt;br /&gt;dataSet.AcceptChanges();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;#endregion&lt;br /&gt;#region CreateCommand&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Simplify the creation of a Sql command object by allowing&lt;br /&gt;/// a stored procedure and optional parameters to be provided&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// e.g.:&lt;br /&gt;/// MySqlCommand command = CreateCommand(conn, "AddCustomer", "CustomerID", "CustomerName");&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="connection"&gt;A valid MySqlConnection object&lt;/param&gt;&lt;br /&gt;/// &lt;param name="spName"&gt;The name of the stored procedure&lt;/param&gt;&lt;br /&gt;/// &lt;param name="sourceColumns"&gt;An array of string to be assigned as the source columns of the stored procedure parameters&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;A valid MySqlCommand object&lt;/returns&gt;&lt;br /&gt;public static MySqlCommand CreateCommand(MySqlConnection connection, string spName, params string[] sourceColumns)&lt;br /&gt;{&lt;br /&gt;if (connection == null) throw new ArgumentNullException("connection");&lt;br /&gt;if (spName == null  spName.Length == 0) throw new ArgumentNullException("spName");&lt;br /&gt;// Create a MySqlCommand&lt;br /&gt;MySqlCommand cmd = new MySqlCommand(spName, connection);&lt;br /&gt;cmd.CommandType = CommandType.StoredProcedure;&lt;br /&gt;// If we receive parameter values, we need to figure out where they go&lt;br /&gt;if ((sourceColumns != null) &amp;amp;&amp;amp; (sourceColumns.Length &gt; 0))&lt;br /&gt;{&lt;br /&gt;// Pull the parameters for this stored procedure from the parameter cache (or discover them &amp;amp; populate the cache)&lt;br /&gt;MySqlParameter[] commandParameters = MySqlHelperParameterCache.GetSpParameterSet(connection, spName);&lt;br /&gt;// Assign the provided source columns to these parameters based on parameter order&lt;br /&gt;for (int index = 0; index &lt; sourceColumns.Length; index++)&lt;br /&gt;commandParameters[index].SourceColumn = sourceColumns[index];&lt;br /&gt;// Attach the discovered parameters to the MySqlCommand object&lt;br /&gt;AttachParameters(cmd, commandParameters);&lt;br /&gt;}&lt;br /&gt;return cmd;&lt;br /&gt;}&lt;br /&gt;#endregion&lt;br /&gt;#region ExecuteNonQueryTypedParams&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a stored procedure via a MySqlCommand (that returns no resultset) against the database specified in&lt;br /&gt;/// the connection string using the dataRow column values as the stored procedure's parameters values.&lt;br /&gt;/// This method will query the database to discover the parameters for the&lt;br /&gt;/// stored procedure (the first time each stored procedure is called), and assign the values based on row values.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="connectionString"&gt;A valid connection string for a MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="spName"&gt;The name of the stored procedure&lt;/param&gt;&lt;br /&gt;/// &lt;param name="dataRow"&gt;The dataRow used to hold the stored procedure's parameter values.&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;An int representing the number of rows affected by the command&lt;/returns&gt;&lt;br /&gt;public static int ExecuteNonQueryTypedParams(String connectionString, String spName, DataRow dataRow)&lt;br /&gt;{&lt;br /&gt;if (connectionString == null  connectionString.Length == 0) throw new ArgumentNullException("connectionString");&lt;br /&gt;if (spName == null  spName.Length == 0) throw new ArgumentNullException("spName");&lt;br /&gt;// If the row has values, the store procedure parameters must be initialized&lt;br /&gt;if (dataRow != null &amp;amp;&amp;amp; dataRow.ItemArray.Length &gt; 0)&lt;br /&gt;{&lt;br /&gt;// Pull the parameters for this stored procedure from the parameter cache (or discover them &amp;amp; populate the cache)&lt;br /&gt;MySqlParameter[] commandParameters = MySqlHelperParameterCache.GetSpParameterSet(connectionString, spName);&lt;br /&gt;// Set the parameters values&lt;br /&gt;AssignParameterValues(commandParameters, dataRow);&lt;br /&gt;return MySqlHelper.ExecuteNonQuery(connectionString, spName, commandParameters);&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;return MySqlHelper.ExecuteNonQuery(connectionString, spName);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a stored procedure via a MySqlCommand (that returns no resultset) against the specified MySqlConnection&lt;br /&gt;/// using the dataRow column values as the stored procedure's parameters values.&lt;br /&gt;/// This method will query the database to discover the parameters for the&lt;br /&gt;/// stored procedure (the first time each stored procedure is called), and assign the values based on row values.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="connection"&gt;A valid MySqlConnection object&lt;/param&gt;&lt;br /&gt;/// &lt;param name="spName"&gt;The name of the stored procedure&lt;/param&gt;&lt;br /&gt;/// &lt;param name="dataRow"&gt;The dataRow used to hold the stored procedure's parameter values.&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;An int representing the number of rows affected by the command&lt;/returns&gt;&lt;br /&gt;public static int ExecuteNonQueryTypedParams(MySqlConnection connection, String spName, DataRow dataRow)&lt;br /&gt;{&lt;br /&gt;if (connection == null) throw new ArgumentNullException("connection");&lt;br /&gt;if (spName == null  spName.Length == 0) throw new ArgumentNullException("spName");&lt;br /&gt;// If the row has values, the store procedure parameters must be initialized&lt;br /&gt;if (dataRow != null &amp;amp;&amp;amp; dataRow.ItemArray.Length &gt; 0)&lt;br /&gt;{&lt;br /&gt;// Pull the parameters for this stored procedure from the parameter cache (or discover them &amp;amp; populate the cache)&lt;br /&gt;MySqlParameter[] commandParameters = MySqlHelperParameterCache.GetSpParameterSet(connection, spName);&lt;br /&gt;// Set the parameters values&lt;br /&gt;AssignParameterValues(commandParameters, dataRow);&lt;br /&gt;return MySqlHelper.ExecuteNonQuery(connection, spName, commandParameters);&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;return MySqlHelper.ExecuteNonQuery(connection, spName);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;#endregion&lt;br /&gt;#region ExecuteDatasetTypedParams&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a stored procedure via a MySqlCommand (that returns a resultset) against the database specified in&lt;br /&gt;/// the connection string using the dataRow column values as the stored procedure's parameters values.&lt;br /&gt;/// This method will query the database to discover the parameters for the&lt;br /&gt;/// stored procedure (the first time each stored procedure is called), and assign the values based on row values.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="connectionString"&gt;A valid connection string for a MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="spName"&gt;The name of the stored procedure&lt;/param&gt;&lt;br /&gt;/// &lt;param name="dataRow"&gt;The dataRow used to hold the stored procedure's parameter values.&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;A dataset containing the resultset generated by the command&lt;/returns&gt;&lt;br /&gt;public static DataSet ExecuteDatasetTypedParams(string connectionString, String spName, DataRow dataRow)&lt;br /&gt;{&lt;br /&gt;if (connectionString == null  connectionString.Length == 0) throw new ArgumentNullException("connectionString");&lt;br /&gt;if (spName == null  spName.Length == 0) throw new ArgumentNullException("spName");&lt;br /&gt;//If the row has values, the store procedure parameters must be initialized&lt;br /&gt;if (dataRow != null &amp;amp;&amp;amp; dataRow.ItemArray.Length &gt; 0)&lt;br /&gt;{&lt;br /&gt;// Pull the parameters for this stored procedure from the parameter cache (or discover them &amp;amp; populate the cache)&lt;br /&gt;MySqlParameter[] commandParameters = MySqlHelperParameterCache.GetSpParameterSet(connectionString, spName);&lt;br /&gt;// Set the parameters values&lt;br /&gt;AssignParameterValues(commandParameters, dataRow);&lt;br /&gt;return MySqlHelper.ExecuteDataset(connectionString, spName, commandParameters);&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;return MySqlHelper.ExecuteDataset(connectionString, spName);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a stored procedure via a MySqlCommand (that returns a resultset) against the specified MySqlConnection&lt;br /&gt;/// using the dataRow column values as the store procedure's parameters values.&lt;br /&gt;/// This method will query the database to discover the parameters for the&lt;br /&gt;/// stored procedure (the first time each stored procedure is called), and assign the values based on row values.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="connection"&gt;A valid MySqlConnection object&lt;/param&gt;&lt;br /&gt;/// &lt;param name="spName"&gt;The name of the stored procedure&lt;/param&gt;&lt;br /&gt;/// &lt;param name="dataRow"&gt;The dataRow used to hold the stored procedure's parameter values.&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;A dataset containing the resultset generated by the command&lt;/returns&gt;&lt;br /&gt;public static DataSet ExecuteDatasetTypedParams(MySqlConnection connection, String spName, DataRow dataRow)&lt;br /&gt;{&lt;br /&gt;if (connection == null) throw new ArgumentNullException("connection");&lt;br /&gt;if (spName == null  spName.Length == 0) throw new ArgumentNullException("spName");&lt;br /&gt;// If the row has values, the store procedure parameters must be initialized&lt;br /&gt;if (dataRow != null &amp;amp;&amp;amp; dataRow.ItemArray.Length &gt; 0)&lt;br /&gt;{&lt;br /&gt;// Pull the parameters for this stored procedure from the parameter cache (or discover them &amp;amp; populate the cache)&lt;br /&gt;MySqlParameter[] commandParameters = MySqlHelperParameterCache.GetSpParameterSet(connection, spName);&lt;br /&gt;// Set the parameters values&lt;br /&gt;AssignParameterValues(commandParameters, dataRow);&lt;br /&gt;return MySqlHelper.ExecuteDataset(connection, spName, commandParameters);&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;return MySqlHelper.ExecuteDataset(connection, spName);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;#endregion&lt;br /&gt;#region ExecuteReaderTypedParams&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a stored procedure via a MySqlCommand (that returns a resultset) against the database specified in&lt;br /&gt;/// the connection string using the dataRow column values as the stored procedure's parameters values.&lt;br /&gt;/// This method will query the database to discover the parameters for the&lt;br /&gt;/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="connectionString"&gt;A valid connection string for a MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="spName"&gt;The name of the stored procedure&lt;/param&gt;&lt;br /&gt;/// &lt;param name="dataRow"&gt;The dataRow used to hold the stored procedure's parameter values.&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;A MySqlDataReader containing the resultset generated by the command&lt;/returns&gt;&lt;br /&gt;public static MySqlDataReader ExecuteReaderTypedParams(String connectionString, String spName, DataRow dataRow)&lt;br /&gt;{&lt;br /&gt;if (connectionString == null  connectionString.Length == 0) throw new ArgumentNullException("connectionString");&lt;br /&gt;if (spName == null  spName.Length == 0) throw new ArgumentNullException("spName");&lt;br /&gt;// If the row has values, the store procedure parameters must be initialized&lt;br /&gt;if (dataRow != null &amp;amp;&amp;amp; dataRow.ItemArray.Length &gt; 0)&lt;br /&gt;{&lt;br /&gt;// Pull the parameters for this stored procedure from the parameter cache (or discover them &amp;amp; populate the cache)&lt;br /&gt;MySqlParameter[] commandParameters = MySqlHelperParameterCache.GetSpParameterSet(connectionString, spName);&lt;br /&gt;// Set the parameters values&lt;br /&gt;AssignParameterValues(commandParameters, dataRow);&lt;br /&gt;return MySqlHelper.ExecuteReader(connectionString, spName, commandParameters);&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;return MySqlHelper.ExecuteReader(connectionString, spName);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;　&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a stored procedure via a MySqlCommand (that returns a resultset) against the specified MySqlConnection&lt;br /&gt;/// using the dataRow column values as the stored procedure's parameters values.&lt;br /&gt;/// This method will query the database to discover the parameters for the&lt;br /&gt;/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="connection"&gt;A valid MySqlConnection object&lt;/param&gt;&lt;br /&gt;/// &lt;param name="spName"&gt;The name of the stored procedure&lt;/param&gt;&lt;br /&gt;/// &lt;param name="dataRow"&gt;The dataRow used to hold the stored procedure's parameter values.&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;A MySqlDataReader containing the resultset generated by the command&lt;/returns&gt;&lt;br /&gt;public static MySqlDataReader ExecuteReaderTypedParams(MySqlConnection connection, String spName, DataRow dataRow)&lt;br /&gt;{&lt;br /&gt;if (connection == null) throw new ArgumentNullException("connection");&lt;br /&gt;if (spName == null  spName.Length == 0) throw new ArgumentNullException("spName");&lt;br /&gt;// If the row has values, the store procedure parameters must be initialized&lt;br /&gt;if (dataRow != null &amp;amp;&amp;amp; dataRow.ItemArray.Length &gt; 0)&lt;br /&gt;{&lt;br /&gt;// Pull the parameters for this stored procedure from the parameter cache (or discover them &amp;amp; populate the cache)&lt;br /&gt;MySqlParameter[] commandParameters = MySqlHelperParameterCache.GetSpParameterSet(connection, spName);&lt;br /&gt;// Set the parameters values&lt;br /&gt;AssignParameterValues(commandParameters, dataRow);&lt;br /&gt;return MySqlHelper.ExecuteReader(connection.ConnectionString, spName, commandParameters);&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;return MySqlHelper.ExecuteReader(connection.ConnectionString, spName);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;#endregion&lt;br /&gt;#region ExecuteScalarTypedParams&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a stored procedure via a MySqlCommand (that returns a 1x1 resultset) against the database specified in&lt;br /&gt;/// the connection string using the dataRow column values as the stored procedure's parameters values.&lt;br /&gt;/// This method will query the database to discover the parameters for the&lt;br /&gt;/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="connectionString"&gt;A valid connection string for a MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="spName"&gt;The name of the stored procedure&lt;/param&gt;&lt;br /&gt;/// &lt;param name="dataRow"&gt;The dataRow used to hold the stored procedure's parameter values.&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;An object containing the value in the 1x1 resultset generated by the command&lt;/returns&gt;&lt;br /&gt;public static object ExecuteScalarTypedParams(String connectionString, String spName, DataRow dataRow)&lt;br /&gt;{&lt;br /&gt;if (connectionString == null  connectionString.Length == 0) throw new ArgumentNullException("connectionString");&lt;br /&gt;if (spName == null  spName.Length == 0) throw new ArgumentNullException("spName");&lt;br /&gt;// If the row has values, the store procedure parameters must be initialized&lt;br /&gt;if (dataRow != null &amp;amp;&amp;amp; dataRow.ItemArray.Length &gt; 0)&lt;br /&gt;{&lt;br /&gt;// Pull the parameters for this stored procedure from the parameter cache (or discover them &amp;amp; populate the cache)&lt;br /&gt;MySqlParameter[] commandParameters = MySqlHelperParameterCache.GetSpParameterSet(connectionString, spName);&lt;br /&gt;// Set the parameters values&lt;br /&gt;AssignParameterValues(commandParameters, dataRow);&lt;br /&gt;return MySqlHelper.ExecuteScalar(connectionString, spName, commandParameters);&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;return MySqlHelper.ExecuteScalar(connectionString, spName);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Execute a stored procedure via a MySqlCommand (that returns a 1x1 resultset) against the specified MySqlConnection&lt;br /&gt;/// using the dataRow column values as the stored procedure's parameters values.&lt;br /&gt;/// This method will query the database to discover the parameters for the&lt;br /&gt;/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="connection"&gt;A valid MySqlConnection object&lt;/param&gt;&lt;br /&gt;/// &lt;param name="spName"&gt;The name of the stored procedure&lt;/param&gt;&lt;br /&gt;/// &lt;param name="dataRow"&gt;The dataRow used to hold the stored procedure's parameter values.&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;An object containing the value in the 1x1 resultset generated by the command&lt;/returns&gt;&lt;br /&gt;public static object ExecuteScalarTypedParams(MySqlConnection connection, String spName, DataRow dataRow)&lt;br /&gt;{&lt;br /&gt;if (connection == null) throw new ArgumentNullException("connection");&lt;br /&gt;if (spName == null  spName.Length == 0) throw new ArgumentNullException("spName");&lt;br /&gt;// If the row has values, the store procedure parameters must be initialized&lt;br /&gt;if (dataRow != null &amp;amp;&amp;amp; dataRow.ItemArray.Length &gt; 0)&lt;br /&gt;{&lt;br /&gt;// Pull the parameters for this stored procedure from the parameter cache (or discover them &amp;amp; populate the cache)&lt;br /&gt;MySqlParameter[] commandParameters = MySqlHelperParameterCache.GetSpParameterSet(connection, spName);&lt;br /&gt;// Set the parameters values&lt;br /&gt;AssignParameterValues(commandParameters, dataRow);&lt;br /&gt;return MySqlHelper.ExecuteScalar(connection, spName, commandParameters);&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;return MySqlHelper.ExecuteScalar(connection, spName);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;#endregion&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// MySqlHelperParameterCache provides functions to leverage a static cache of procedure parameters, and the&lt;br /&gt;/// ability to discover parameters for stored procedures at run-time.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;public sealed class MySqlHelperParameterCache&lt;br /&gt;{&lt;br /&gt;#region private methods, variables, and constructors&lt;br /&gt;//Since this class provides only static methods, make the default constructor private to prevent&lt;br /&gt;//instances from being created with "new MySqlHelperParameterCache()"&lt;br /&gt;private MySqlHelperParameterCache() { }&lt;br /&gt;private static Hashtable paramCache = Hashtable.Synchronized(new Hashtable());&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Resolve at run time the appropriate set of MySqlParameters for a stored procedure&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="connection"&gt;A valid MySqlConnection object&lt;/param&gt;&lt;br /&gt;/// &lt;param name="spName"&gt;The name of the stored procedure&lt;/param&gt;&lt;br /&gt;/// &lt;param name="includeReturnValueParameter"&gt;Whether or not to include their return value parameter&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;The parameter array discovered.&lt;/returns&gt;&lt;br /&gt;private static MySqlParameter[] DiscoverSpParameterSet(MySqlConnection connection, string spName, bool includeReturnValueParameter)&lt;br /&gt;{&lt;br /&gt;if (connection == null) throw new ArgumentNullException("connection");&lt;br /&gt;if (spName == null  spName.Length == 0) throw new ArgumentNullException("spName");&lt;br /&gt;MySqlCommand cmd = new MySqlCommand(spName, connection);&lt;br /&gt;cmd.CommandType = CommandType.StoredProcedure;&lt;br /&gt;connection.Open();&lt;br /&gt;MySqlCommandBuilder.DeriveParameters(cmd);&lt;br /&gt;connection.Close();&lt;br /&gt;if (!includeReturnValueParameter)&lt;br /&gt;{&lt;br /&gt;cmd.Parameters.RemoveAt(0);&lt;br /&gt;}&lt;br /&gt;MySqlParameter[] discoveredParameters = new MySqlParameter[cmd.Parameters.Count];&lt;br /&gt;cmd.Parameters.CopyTo(discoveredParameters, 0);&lt;br /&gt;// Init the parameters with a DBNull value&lt;br /&gt;foreach (MySqlParameter discoveredParameter in discoveredParameters)&lt;br /&gt;{&lt;br /&gt;discoveredParameter.Value = DBNull.Value;&lt;br /&gt;}&lt;br /&gt;return discoveredParameters;&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Deep copy of cached MySqlParameter array&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="originalParameters"&gt;&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;private static MySqlParameter[] CloneParameters(MySqlParameter[] originalParameters)&lt;br /&gt;{&lt;br /&gt;MySqlParameter[] clonedParameters = new MySqlParameter[originalParameters.Length];&lt;br /&gt;for (int i = 0, j = originalParameters.Length; i &lt; j; i++)&lt;br /&gt;{&lt;br /&gt;clonedParameters[i] = (MySqlParameter)((ICloneable)originalParameters[i]).Clone();&lt;br /&gt;}&lt;br /&gt;return clonedParameters;&lt;br /&gt;}&lt;br /&gt;#endregion private methods, variables, and constructors&lt;br /&gt;#region caching functions&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Add parameter array to the cache&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="connectionString"&gt;A valid connection string for a MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandParameters"&gt;An array of SqlParamters to be cached&lt;/param&gt;&lt;br /&gt;public static void CacheParameterSet(string connectionString, string commandText, params MySqlParameter[] commandParameters)&lt;br /&gt;{&lt;br /&gt;if (connectionString == null  connectionString.Length == 0) throw new ArgumentNullException("connectionString");&lt;br /&gt;if (commandText == null  commandText.Length == 0) throw new ArgumentNullException("commandText");&lt;br /&gt;string hashKey = connectionString + ":" + commandText;&lt;br /&gt;paramCache[hashKey] = commandParameters;&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Retrieve a parameter array from the cache&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="connectionString"&gt;A valid connection string for a MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="commandText"&gt;The stored procedure name or T-SQL command&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;An array of SqlParamters&lt;/returns&gt;&lt;br /&gt;public static MySqlParameter[] GetCachedParameterSet(string connectionString, string commandText)&lt;br /&gt;{&lt;br /&gt;if (connectionString == null  connectionString.Length == 0) throw new ArgumentNullException("connectionString");&lt;br /&gt;if (commandText == null  commandText.Length == 0) throw new ArgumentNullException("commandText");&lt;br /&gt;string hashKey = connectionString + ":" + commandText;&lt;br /&gt;MySqlParameter[] cachedParameters = paramCache[hashKey] as MySqlParameter[];&lt;br /&gt;if (cachedParameters == null)&lt;br /&gt;{&lt;br /&gt;return null;&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;return CloneParameters(cachedParameters);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;#endregion caching functions&lt;br /&gt;#region Parameter Discovery Functions&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Retrieves the set of MySqlParameters appropriate for the stored procedure&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// This method will query the database for this information, and then store it in a cache for future requests.&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="connectionString"&gt;A valid connection string for a MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="spName"&gt;The name of the stored procedure&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;An array of MySqlParameters&lt;/returns&gt;&lt;br /&gt;public static MySqlParameter[] GetSpParameterSet(string connectionString, string spName)&lt;br /&gt;{&lt;br /&gt;return GetSpParameterSet(connectionString, spName, false);&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Retrieves the set of MySqlParameters appropriate for the stored procedure&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// This method will query the database for this information, and then store it in a cache for future requests.&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="connectionString"&gt;A valid connection string for a MySqlConnection&lt;/param&gt;&lt;br /&gt;/// &lt;param name="spName"&gt;The name of the stored procedure&lt;/param&gt;&lt;br /&gt;/// &lt;param name="includeReturnValueParameter"&gt;A bool value indicating whether the return value parameter should be included in the results&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;An array of MySqlParameters&lt;/returns&gt;&lt;br /&gt;public static MySqlParameter[] GetSpParameterSet(string connectionString, string spName, bool includeReturnValueParameter)&lt;br /&gt;{&lt;br /&gt;if (connectionString == null  connectionString.Length == 0) throw new ArgumentNullException("connectionString");&lt;br /&gt;if (spName == null  spName.Length == 0) throw new ArgumentNullException("spName");&lt;br /&gt;using (MySqlConnection connection = new MySqlConnection(connectionString))&lt;br /&gt;{&lt;br /&gt;return GetSpParameterSetInternal(connection, spName, includeReturnValueParameter);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Retrieves the set of MySqlParameters appropriate for the stored procedure&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// This method will query the database for this information, and then store it in a cache for future requests.&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="connection"&gt;A valid MySqlConnection object&lt;/param&gt;&lt;br /&gt;/// &lt;param name="spName"&gt;The name of the stored procedure&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;An array of MySqlParameters&lt;/returns&gt;&lt;br /&gt;internal static MySqlParameter[] GetSpParameterSet(MySqlConnection connection, string spName)&lt;br /&gt;{&lt;br /&gt;return GetSpParameterSet(connection, spName, false);&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Retrieves the set of MySqlParameters appropriate for the stored procedure&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;remarks&gt;&lt;br /&gt;/// This method will query the database for this information, and then store it in a cache for future requests.&lt;br /&gt;/// &lt;/remarks&gt;&lt;br /&gt;/// &lt;param name="connection"&gt;A valid MySqlConnection object&lt;/param&gt;&lt;br /&gt;/// &lt;param name="spName"&gt;The name of the stored procedure&lt;/param&gt;&lt;br /&gt;/// &lt;param name="includeReturnValueParameter"&gt;A bool value indicating whether the return value parameter should be included in the results&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;An array of MySqlParameters&lt;/returns&gt;&lt;br /&gt;internal static MySqlParameter[] GetSpParameterSet(MySqlConnection connection, string spName, bool includeReturnValueParameter)&lt;br /&gt;{&lt;br /&gt;if (connection == null) throw new ArgumentNullException("connection");&lt;br /&gt;using (MySqlConnection clonedConnection = (MySqlConnection)((ICloneable)connection).Clone())&lt;br /&gt;{&lt;br /&gt;return GetSpParameterSetInternal(clonedConnection, spName, includeReturnValueParameter);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Retrieves the set of MySqlParameters appropriate for the stored procedure&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="connection"&gt;A valid MySqlConnection object&lt;/param&gt;&lt;br /&gt;/// &lt;param name="spName"&gt;The name of the stored procedure&lt;/param&gt;&lt;br /&gt;/// &lt;param name="includeReturnValueParameter"&gt;A bool value indicating whether the return value parameter should be included in the results&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;An array of MySqlParameters&lt;/returns&gt;&lt;br /&gt;private static MySqlParameter[] GetSpParameterSetInternal(MySqlConnection connection, string spName, bool includeReturnValueParameter)&lt;br /&gt;{&lt;br /&gt;if (connection == null) throw new ArgumentNullException("connection");&lt;br /&gt;if (spName == null  spName.Length == 0) throw new ArgumentNullException("spName");&lt;br /&gt;string hashKey = connection.ConnectionString + ":" + spName + (includeReturnValueParameter ? ":include ReturnValue Parameter" : "");&lt;br /&gt;MySqlParameter[] cachedParameters;&lt;br /&gt;cachedParameters = paramCache[hashKey] as MySqlParameter[];&lt;br /&gt;if (cachedParameters == null)&lt;br /&gt;{&lt;br /&gt;MySqlParameter[] spParameters = DiscoverSpParameterSet(connection, spName, includeReturnValueParameter);&lt;br /&gt;paramCache[hashKey] = spParameters;&lt;br /&gt;cachedParameters = spParameters;&lt;br /&gt;}&lt;br /&gt;return CloneParameters(cachedParameters);&lt;br /&gt;}&lt;br /&gt;#endregion Parameter Discovery Functions&lt;br /&gt;}&lt;br /&gt;　&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6441553613064463233-7200816854936828091?l=sudhironline.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sudhironline.blogspot.com/feeds/7200816854936828091/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sudhironline.blogspot.com/2009/07/migrating-aspnet-application-from-ms.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6441553613064463233/posts/default/7200816854936828091'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6441553613064463233/posts/default/7200816854936828091'/><link rel='alternate' type='text/html' href='http://sudhironline.blogspot.com/2009/07/migrating-aspnet-application-from-ms.html' title='Migrating an ASP.NET application from MS SQL Server To MySQL'/><author><name>Sudhir Dwivedi's .NET Blog</name><uri>http://www.blogger.com/profile/03672675458059523580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='http://2.bp.blogspot.com/_5vvvyC6SDJw/SVfhD8QpsnI/AAAAAAAAAA8/yM02BEUraxg/S220/sudhirindubai.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6441553613064463233.post-7066378377746146834</id><published>2009-07-08T04:19:00.000-07:00</published><updated>2009-07-08T05:40:21.634-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='BCP'/><category scheme='http://www.blogger.com/atom/ns#' term='Data Integration'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><category scheme='http://www.blogger.com/atom/ns#' term='Quartz.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='WCF'/><title type='text'>I completed 1 year with BrickRed</title><content type='html'>Yesterday I woke up in the morning overhearing a little discussion between my elder brother and a delivery boy at door. Actually my company had sent a buquet and greeting cards for me on the occasion of completing one year with the company.&lt;br /&gt;&lt;br /&gt;I wanted to share my one year summary yesterday only but I got now that to share due to certain unavoidable things.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_5vvvyC6SDJw/SlSG98iU9dI/AAAAAAAAABw/3AJ3kxOygpA/s1600-h/true.gif"&gt;&lt;img style="MARGIN: 0px 10px 10px 0px; WIDTH: 16px; FLOAT: left; HEIGHT: 16px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5356054255630611922" border="0" alt="" src="http://2.bp.blogspot.com/_5vvvyC6SDJw/SlSG98iU9dI/AAAAAAAAABw/3AJ3kxOygpA/s320/true.gif" /&gt;&lt;/a&gt;I was hired for an Upload Module for a client dealing in Mortgage domain. The idea behind the project was to get the data from various users/clients/financial instutions in their specific format having their own schemas to be uploaded in an uniform database schema of the vendor. I was told to provide a smart client as well as scheduled windows services using FTP pickup solution. It was very exciting opportunity. I enjoyed it alongwith my manager and another team member. The main chunk was to write SQL to upload data in various tables with all robust mechanism like Transactions, Errors, Reportings, Queues, Recycling etc..&lt;br /&gt;My Manger was thinking very seriously to make it as a product. I played a lot in windows services and Quartz.NET as well. It was a nice assignment and the best at that time :).&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_5vvvyC6SDJw/SlSG98iU9dI/AAAAAAAAABw/3AJ3kxOygpA/s1600-h/true.gif"&gt;&lt;img style="MARGIN: 0px 10px 10px 0px; WIDTH: 16px; FLOAT: left; HEIGHT: 16px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5356054255630611922" border="0" alt="" src="http://2.bp.blogspot.com/_5vvvyC6SDJw/SlSG98iU9dI/AAAAAAAAABw/3AJ3kxOygpA/s320/true.gif" /&gt;&lt;/a&gt;Next I worked on a similar assignment for aviation domain. But this time data was coming in hetrogenous file formats. So I was told to write parsers and use .NET reflection to load parser's assemply at runtime. as this time database used was Oracle 10g. So it was nice to work in Array based method counterpart to BCP in SQL server. I got a true experience writing stored procedures and managing other objects in Oracle 10g. I got some DBA experience as well ;).&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_5vvvyC6SDJw/SlSG98iU9dI/AAAAAAAAABw/3AJ3kxOygpA/s1600-h/true.gif"&gt;&lt;img style="MARGIN: 0px 10px 10px 0px; WIDTH: 16px; FLOAT: left; HEIGHT: 16px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5356054255630611922" border="0" alt="" src="http://2.bp.blogspot.com/_5vvvyC6SDJw/SlSG98iU9dI/AAAAAAAAABw/3AJ3kxOygpA/s320/true.gif" /&gt;&lt;/a&gt;Next I was awarded with another assignment for BPMS (Business Process Management System) suite. I was told to write components for that and certain pages on MVP model. The client was using their proprietary tool for ORM. Apart from the technical stuff, It's mentioning a worth here that I learnt a little Spanish too because client was from Argentina. And people there were not very good in English... thanks Google Translation and that girl from client side ;) she helped me in learning .... gracias!!&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_5vvvyC6SDJw/SlSG98iU9dI/AAAAAAAAABw/3AJ3kxOygpA/s1600-h/true.gif"&gt;&lt;img style="MARGIN: 0px 10px 10px 0px; WIDTH: 16px; FLOAT: left; HEIGHT: 16px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5356054255630611922" border="0" alt="" src="http://2.bp.blogspot.com/_5vvvyC6SDJw/SlSG98iU9dI/AAAAAAAAABw/3AJ3kxOygpA/s320/true.gif" /&gt;&lt;/a&gt;Next I was given a Reporting services assignment for a big company. I already mentioned about the project in a previous blog.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_5vvvyC6SDJw/SlSG98iU9dI/AAAAAAAAABw/3AJ3kxOygpA/s1600-h/true.gif"&gt;&lt;img style="MARGIN: 0px 10px 10px 0px; WIDTH: 16px; FLOAT: left; HEIGHT: 16px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5356054255630611922" border="0" alt="" src="http://2.bp.blogspot.com/_5vvvyC6SDJw/SlSG98iU9dI/AAAAAAAAABw/3AJ3kxOygpA/s320/true.gif" /&gt;&lt;/a&gt;Currently I am working for loyalty based client. I hope I' ll invest my good and quality time for this project for a certain good amount of time. I have been working on short term assignments where lots of technical versatilities/intricacies were involved. &lt;br /&gt;..........Looking forward to utilize my best for upcoming assignments... Thanks to the people I worked with : )&lt;br /&gt;&lt;br /&gt;Best Regards&lt;br /&gt;Sudhir&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6441553613064463233-7066378377746146834?l=sudhironline.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sudhironline.blogspot.com/feeds/7066378377746146834/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sudhironline.blogspot.com/2009/07/i-completed-1-year-with-brickred.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6441553613064463233/posts/default/7066378377746146834'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6441553613064463233/posts/default/7066378377746146834'/><link rel='alternate' type='text/html' href='http://sudhironline.blogspot.com/2009/07/i-completed-1-year-with-brickred.html' title='I completed 1 year with BrickRed'/><author><name>Sudhir Dwivedi's .NET Blog</name><uri>http://www.blogger.com/profile/03672675458059523580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='http://2.bp.blogspot.com/_5vvvyC6SDJw/SVfhD8QpsnI/AAAAAAAAAA8/yM02BEUraxg/S220/sudhirindubai.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_5vvvyC6SDJw/SlSG98iU9dI/AAAAAAAAABw/3AJ3kxOygpA/s72-c/true.gif' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6441553613064463233.post-5096043362291256846</id><published>2009-07-04T07:30:00.000-07:00</published><updated>2009-07-24T06:03:22.597-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Dynamic Reports in SQL Server Reporting Services 2008'/><title type='text'>Dynamic Reports in SQL Server Reporting Services 2008</title><content type='html'>&lt;strong&gt;Problem Summary&lt;/strong&gt;:&lt;br /&gt;My last assignment was on SQL Server Reporting Services 2008. I was given to create/export direclty (into excel or pdf format) reports from ASP.NET web interface basis the search criterias where number of the columns were not fixed; columns were supposed to come from the rows of queries.&lt;br /&gt;Now prabibly a question tosses in your mind Why SSRS, not the traditional way of COM/office component to write excel file instead of exporting by SSRS things. The answer is to uniform the development/runtime environment with stronger .NET based things. and off course to implement security for report access with SSRS 2008. Also reports can be bind any time with Report Viewer Control.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;So what I did:&lt;/strong&gt;&lt;br /&gt;1. Wrote stored procedure to result data passing the search criterias; off course lots of dynamic sql to make columns based on the rows in the query results for specific input parameters and then populating desired data to those columns based on the certain manipulations.&lt;br /&gt;2. Generated memory stream of .rdl (Report definition language) based on the dynamic schema being resulted after executing the stored procedures created in the first step. It involves lots of C# code to write XML format of rdl formatting and binding the data elements to the report skeleton.&lt;br /&gt;3. Exported report in the desired format(.xls/pdf etc.) using the compiled proxy class of the Report Server Web service Library (ReportingService2005.dll).&lt;br /&gt;&lt;br /&gt;Yes It was really a challenging stuff recently I faced.&lt;br /&gt;I would like to share with you in detail if you are doing the similar kind of stuff.&lt;br /&gt;&lt;br /&gt;Cheers!!&lt;br /&gt;Sudhir&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6441553613064463233-5096043362291256846?l=sudhironline.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sudhironline.blogspot.com/feeds/5096043362291256846/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sudhironline.blogspot.com/2009/07/dynamic-reports-in-sql-server-reporting.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6441553613064463233/posts/default/5096043362291256846'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6441553613064463233/posts/default/5096043362291256846'/><link rel='alternate' type='text/html' href='http://sudhironline.blogspot.com/2009/07/dynamic-reports-in-sql-server-reporting.html' title='Dynamic Reports in SQL Server Reporting Services 2008'/><author><name>Sudhir Dwivedi's .NET Blog</name><uri>http://www.blogger.com/profile/03672675458059523580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='http://2.bp.blogspot.com/_5vvvyC6SDJw/SVfhD8QpsnI/AAAAAAAAAA8/yM02BEUraxg/S220/sudhirindubai.jpg'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6441553613064463233.post-4673107175927503107</id><published>2009-06-29T05:56:00.000-07:00</published><updated>2009-07-08T05:46:20.778-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Noida'/><category scheme='http://www.blogger.com/atom/ns#' term='BrickRed Technologies'/><title type='text'>Introduction</title><content type='html'>I was waiting for the day when I would be writing my first blog. I am completing 1 year with my current organization -&lt;a href="http://www.brickred.com/"&gt;BrickRed Technologies&lt;/a&gt;, Noida on 7th July. Before joining BrickRed I was working with &lt;a href="http://www.3i-infotech.com/"&gt;3i-Infotech Ltd&lt;/a&gt;. BrickRed has provided me tremendous opportunities to utilize my potentials and to pave my way towards the solid ground of professionalism.&lt;br /&gt;I have completed my 5.5 years of development experience. I started my career with Hi-Tech Services ( a very small venture started by a highly motivated man having a peculiar vision of B2B web solutions), New Delhi as an ASP/COM Developer, later I worked on ASP.NET and SQL Server. I also worked with LSMC, &lt;a href="http://scienceoflife.com/"&gt;ScienceofLife.com&lt;/a&gt; for quite some time starting with very basic module to setup it as an Intgrative healthcare research platform. It was having a huge database of healthcare related entities.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Resume Summary:&lt;/strong&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Wide experience in Thin, Thick, Smart Client and Database applications development on Microsoft Techs: Web Services, Web Forms, Win Forms, SQL Server, IIS, AJAX, Win Servers and Reporting Tools. &lt;/li&gt;&lt;li&gt;Worked as a .NET Consultant, Sr. Developer, Developer for top-notch clients &amp;amp; having overseas on-site exposure.&lt;/li&gt;&lt;li&gt;Good experience and keen interest in Databases such as Oracle &amp;amp; MS SQL including Reporting Services and Analysis Services&lt;/li&gt;&lt;li&gt;Good exposure of the complete SDLC. Proactively involved in requirements analysis, project planning, design, development and deployment activities&lt;/li&gt;&lt;li&gt;Followed the best patterns and practices for N-Tier Applications with all design and architectural compliances.Good command over security majors&lt;/li&gt;&lt;li&gt;Expertise in Multi linguistic application development.&lt;/li&gt;&lt;li&gt;Very good analytical and problem solving approach. Having ability to work within tight timelines. Foresight to handle upcoming issues&lt;/li&gt;&lt;li&gt;Good Domain Knowledge of GIS, Health care, e-Gov, e-Commerce. Mortgage and BPMS suites.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;Core Skills:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;&lt;li&gt;RunTime: .NET 1.0 to 4.0&lt;/li&gt;&lt;li&gt;PLs: C# (1.0,to 4.0), VB.NET, J#&lt;/li&gt;&lt;li&gt;Web: ASP.NET, XHTML, XML, JavaScript, AJAX, Web Services&lt;/li&gt;&lt;li&gt;App servers: IIS 5.0/6.0, MOSS 2007&lt;/li&gt;&lt;li&gt;IDE &amp;amp; SourceSafe: VS.NET 2002 to 2010, VSS,SVN, TFS&lt;/li&gt;&lt;li&gt;DB: MS SQL7.0 to 2008, Oracle 9i R2 &amp;amp; 10g&lt;/li&gt;&lt;li&gt;BI &amp;amp; Reporting: SSIS, SSRS, SSAS and Crystal Reports.&lt;/li&gt;&lt;li&gt;OS: Win 2000, 2003 Server, XP Pro.&lt;/li&gt;&lt;li&gt;SE Tools: MS-Visio 2003, 2005, Architect&lt;/li&gt;&lt;li&gt;Other: Infragistics UI Set, Google Map API, Nant, NUnit, Log4net, NHibernate, Ektron &lt;/li&gt;&lt;li&gt;Frameworks: N-Tier, MVC, MVP&lt;/li&gt;&lt;li&gt;Agile: DSDM, FDD/TDD, Scrum&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6441553613064463233-4673107175927503107?l=sudhironline.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sudhironline.blogspot.com/feeds/4673107175927503107/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sudhironline.blogspot.com/2009/06/introduction.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6441553613064463233/posts/default/4673107175927503107'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6441553613064463233/posts/default/4673107175927503107'/><link rel='alternate' type='text/html' href='http://sudhironline.blogspot.com/2009/06/introduction.html' title='Introduction'/><author><name>Sudhir Dwivedi's .NET Blog</name><uri>http://www.blogger.com/profile/03672675458059523580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='http://2.bp.blogspot.com/_5vvvyC6SDJw/SVfhD8QpsnI/AAAAAAAAAA8/yM02BEUraxg/S220/sudhirindubai.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6441553613064463233.post-4181668647260034378</id><published>2009-03-19T00:43:00.000-07:00</published><updated>2009-08-26T05:15:32.119-07:00</updated><title type='text'>First Post</title><content type='html'>I am highly indebted of the technical community. I started my technical (IT) journey in year 2001. I was pursuing Masters in Computer Applications. My teacher had given me an assignment to prepare a report on Pentium Bug. I was searching on all the search engines and it was my first intensive search experience. I was astonished at the fact who is sharing all this and why.&lt;br /&gt;&lt;br /&gt;I started my official career in Jan 2004 as a trainee for some really exciting COM based MIS application. And like other millions of people I have been taking lots of help from the online community.&lt;br /&gt;Though, there were a few instances when I couldn't find answers for my tech issues. I found they are really something new or rare. Therefore, it was my moral duty to share with others.&lt;br /&gt;&lt;br /&gt;In this blog though my focus is on Microsoft Technologies (as I am working mostly for .NET platform), But personally I am not labelled for any limitations.&lt;br /&gt;&lt;br /&gt;Hmmm.......&lt;br /&gt;&lt;br /&gt;I hope to be useful at some extent.&lt;br /&gt;Best Regards,&lt;br /&gt;Sudhir&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6441553613064463233-4181668647260034378?l=sudhironline.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sudhironline.blogspot.com/feeds/4181668647260034378/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sudhironline.blogspot.com/2009/03/first-post.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6441553613064463233/posts/default/4181668647260034378'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6441553613064463233/posts/default/4181668647260034378'/><link rel='alternate' type='text/html' href='http://sudhironline.blogspot.com/2009/03/first-post.html' title='First Post'/><author><name>Sudhir Dwivedi's .NET Blog</name><uri>http://www.blogger.com/profile/03672675458059523580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='http://2.bp.blogspot.com/_5vvvyC6SDJw/SVfhD8QpsnI/AAAAAAAAAA8/yM02BEUraxg/S220/sudhirindubai.jpg'/></author><thr:total>0</thr:total></entry></feed>
