Sync the ByteFX source tree to the latest version:
authorDuncan Mak <duncan@mono-cvs.ximian.com>
Tue, 18 May 2004 03:16:43 +0000 (03:16 -0000)
committerDuncan Mak <duncan@mono-cvs.ximian.com>
Tue, 18 May 2004 03:16:43 +0000 (03:16 -0000)
http://www.bytefx.com/releases/ByteFX.MySqlClient.76.src.zip

svn path=/trunk/mcs/; revision=27556

59 files changed:
mcs/class/ByteFX.Data/AssemblyInfo.cs
mcs/class/ByteFX.Data/ChangeLog.txt
mcs/class/ByteFX.Data/Common/BitStream.cs
mcs/class/ByteFX.Data/Common/Connection.cs
mcs/class/ByteFX.Data/Common/ConnectionString.cs
mcs/class/ByteFX.Data/Common/DBConnectionString.cs
mcs/class/ByteFX.Data/Common/DBParametersEditor.cs
mcs/class/ByteFX.Data/Common/Field.cs
mcs/class/ByteFX.Data/Common/HuffmanTree.cs
mcs/class/ByteFX.Data/Common/Inflater.cs
mcs/class/ByteFX.Data/Common/MultiHostStream.cs
mcs/class/ByteFX.Data/Common/NamedPipeStream.cs
mcs/class/ByteFX.Data/Common/Platform.cs [new file with mode: 0644]
mcs/class/ByteFX.Data/Common/Security.cs
mcs/class/ByteFX.Data/Common/StreamCreator.cs [new file with mode: 0644]
mcs/class/ByteFX.Data/Common/StringUtility.cs
mcs/class/ByteFX.Data/Common/Version.cs
mcs/class/ByteFX.Data/MySqlClient.csproj [new file with mode: 0644]
mcs/class/ByteFX.Data/lgpl.txt
mcs/class/ByteFX.Data/mysqlclient/CharSetMap.cs
mcs/class/ByteFX.Data/mysqlclient/CommandBuilder.cs
mcs/class/ByteFX.Data/mysqlclient/CommandResult.cs [new file with mode: 0644]
mcs/class/ByteFX.Data/mysqlclient/CompressedStream.cs [new file with mode: 0644]
mcs/class/ByteFX.Data/mysqlclient/Connection.cs
mcs/class/ByteFX.Data/mysqlclient/Connection.resx
mcs/class/ByteFX.Data/mysqlclient/ConnectionInternal.cs
mcs/class/ByteFX.Data/mysqlclient/ConnectionString.cs
mcs/class/ByteFX.Data/mysqlclient/Driver.cs
mcs/class/ByteFX.Data/mysqlclient/Exception.cs
mcs/class/ByteFX.Data/mysqlclient/Field.cs
mcs/class/ByteFX.Data/mysqlclient/MySqlError.cs [new file with mode: 0644]
mcs/class/ByteFX.Data/mysqlclient/MySqlHelper.cs
mcs/class/ByteFX.Data/mysqlclient/MySqlPool.cs
mcs/class/ByteFX.Data/mysqlclient/MySqlPoolManager.cs
mcs/class/ByteFX.Data/mysqlclient/MySqlStream.cs
mcs/class/ByteFX.Data/mysqlclient/MysqlDefs.cs
mcs/class/ByteFX.Data/mysqlclient/Packet.cs
mcs/class/ByteFX.Data/mysqlclient/command.cs
mcs/class/ByteFX.Data/mysqlclient/command.resx
mcs/class/ByteFX.Data/mysqlclient/dataadapter.cs
mcs/class/ByteFX.Data/mysqlclient/datareader.cs
mcs/class/ByteFX.Data/mysqlclient/docs/MySqlCommand.xml [new file with mode: 0644]
mcs/class/ByteFX.Data/mysqlclient/docs/MySqlCommandBuilder.xml [new file with mode: 0644]
mcs/class/ByteFX.Data/mysqlclient/docs/MySqlConnection.xml [new file with mode: 0644]
mcs/class/ByteFX.Data/mysqlclient/docs/MySqlDataAdapter.xml [new file with mode: 0644]
mcs/class/ByteFX.Data/mysqlclient/docs/MySqlDataReader.xml [new file with mode: 0644]
mcs/class/ByteFX.Data/mysqlclient/docs/MySqlException.xml [new file with mode: 0644]
mcs/class/ByteFX.Data/mysqlclient/docs/MySqlHelper.xml [new file with mode: 0644]
mcs/class/ByteFX.Data/mysqlclient/docs/MySqlParameter.xml [new file with mode: 0644]
mcs/class/ByteFX.Data/mysqlclient/docs/MySqlParameterCollection.xml [new file with mode: 0644]
mcs/class/ByteFX.Data/mysqlclient/docs/MySqlTransaction.xml [new file with mode: 0644]
mcs/class/ByteFX.Data/mysqlclient/parameter.cs
mcs/class/ByteFX.Data/mysqlclient/parameter_collection.cs
mcs/class/ByteFX.Data/mysqlclient/resources/command.bmp [new file with mode: 0644]
mcs/class/ByteFX.Data/mysqlclient/resources/connection.bmp [new file with mode: 0644]
mcs/class/ByteFX.Data/mysqlclient/resources/dataadapter.bmp [new file with mode: 0644]
mcs/class/ByteFX.Data/mysqlclient/todo.txt
mcs/class/ByteFX.Data/mysqlclient/transaction.cs [new file with mode: 0644]
mcs/class/ByteFX.Data/readme.txt

index a0aaf9229df7bdd3c5c9f9de88897fa06ae9132d..dd0bf59230d47e6da265b6e38559739dfd85810d 100755 (executable)
@@ -1,38 +1,60 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-
-//
-// General Information about an assembly is controlled through the following 
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-//
-[assembly: AssemblyTitle("ByteFX.Data.dll")]
-[assembly: AssemblyDescription("ADO.Net drivers for MySql & PostgreSQL")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("ByteFX, Inc.")]
-[assembly: AssemblyProduct("")]
-[assembly: AssemblyCopyright("Copyright 2002-2003, ByteFX, Inc.")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]                
-
-//
-// Version information for an assembly consists of the following four values:
-//
-//      Major Version
-//      Minor Version 
-//      Build Number
-//      Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers 
-// by using the '*' as shown below:
-
-#if (NET_2_0)
-       [assembly: AssemblyVersion ("0.7.4.2")]
-#elif (NET_1_1)
-       [assembly: AssemblyVersion ("0.7.4.1")]
-#else
-       [assembly: AssemblyVersion ("0.7.4.0")]
-#endif
-
-[assembly: AssemblyDelaySign (true)]
-[assembly: AssemblyKeyFile ("../mono.pub")]
+using System.Reflection;\r
+using System.Runtime.CompilerServices;\r
+\r
+//\r
+// General Information about an assembly is controlled through the following \r
+// set of attributes. Change these attribute values to modify the information\r
+// associated with an assembly.\r
+//\r
+[assembly: AssemblyTitle("ByteFX.MySqlClient.dll")]\r
+[assembly: AssemblyDescription("ADO.Net driver for MySql")]\r
+[assembly: AssemblyConfiguration("")]\r
+[assembly: AssemblyCompany("ByteFX, Inc.")]\r
+[assembly: AssemblyProduct("")]\r
+[assembly: AssemblyCopyright("Copyright 2002-2004, ByteFX, Inc.")]\r
+[assembly: AssemblyTrademark("")]\r
+[assembly: AssemblyCulture("")]                \r
+\r
+//\r
+// Version information for an assembly consists of the following four values:\r
+//\r
+//      Major Version\r
+//      Minor Version \r
+//      Build Number\r
+//      Revision\r
+//\r
+// You can specify all the values or you can default the Revision and Build Numbers \r
+// by using the '*' as shown below:\r
+\r
+[assembly: AssemblyVersion("0.7.6.*")]\r
+\r
+//\r
+// In order to sign your assembly you must specify a key to use. Refer to the \r
+// Microsoft .NET Framework documentation for more information on assembly signing.\r
+//\r
+// Use the attributes below to control which key is used for signing. \r
+//\r
+// Notes: \r
+//   (*) If no key is specified, the assembly is not signed.\r
+//   (*) KeyName refers to a key that has been installed in the Crypto Service\r
+//       Provider (CSP) on your machine. KeyFile refers to a file which contains\r
+//       a key.\r
+//   (*) If the KeyFile and the KeyName values are both specified, the \r
+//       following processing occurs:\r
+//       (1) If the KeyName can be found in the CSP, that key is used.\r
+//       (2) If the KeyName does not exist and the KeyFile does exist, the key \r
+//           in the KeyFile is installed into the CSP and used.\r
+//   (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.\r
+//       When specifying the KeyFile, the location of the KeyFile should be\r
+//       relative to the project output directory which is\r
+//       %Project Directory%\obj\<configuration>. For example, if your KeyFile is\r
+//       located in the project directory, you would specify the AssemblyKeyFile \r
+//       attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]\r
+//   (*) Delay Signing is an advanced option - see the Microsoft .NET Framework\r
+//       documentation for more information on this.\r
+//\r
+[assembly: AssemblyDelaySign(false)]\r
+#if WINDOWS || !DEBUG\r
+[assembly: AssemblyKeyFile(@"d:\projects\ByteFX\bytefx.snk")]\r
+#endif\r
+[assembly: AssemblyKeyName("")]\r
index 3a805d686e13ce797921781d304026b44a9a5795..ff5d2ea85b66a76e3a6ae32a9ab5219c32d9b548 100755 (executable)
-11/30/2003
-MySql - Fixed ConnectionSTring editor dialog (thanks marco p (pomarc))
-Common - UserId now supported in connection strings (thanks Jeff Neeley)
-MySql - Attempting to create a parameter that is not input throws an exception (thanks Ryan Gregg)
-
-11/29/2003 
-MySql - Added much documentation
-
-11/26/2003
-MySql - checked in new MultiHostStream capability.  Big thanks to Dan Guisinger for this.  he originally submitted the code and idea of supporting multiple machines on the connect string.
-
-11/25/2003
-MySql - Added alot of documentation.  Still alot to do.
-
-11/24/2003
-MySql - Fixed speed issue with 0.73
-
-11/14/2003
-MySql - changed to Thread.Sleep(0) in MySqlDataStream to help optimize the case where it doesn't need to wait (thanks Todd German)
-11/1/2003
-MySql - Prepopulating the idlepools to MinPoolSize
-
-10/31/2003
-MySql - Fixed MySqlPool deadlock condition as well as stupid bug where CreateNewPooledConnection
-        was not ever adding new connections to the pool.
-       Also fixed MySqlStream.ReadBytes and ReadByte to not use TicksPerSecond which does not appear
-       to always be right.
-       (thanks Matthew J. Peddlesden)
-MySql - Fix for precision and scale (thanks Matthew J. Peddlesden)
-
-10/28/2003
-MySql - Added Thread.Sleep(1) to stream reading methods to be more cpu friendly (thanks Sean McGinnis)
-
-10/24/2003
-MySql - Fixed problem where ExecuteReader would sometime return null (thanks Lloyd Dupont )
-
-10/17/2003
-MySql - Fixed major bug with null field handling (thanks Naucki)
-
-10/15/2003
-MySql - enclosed queries for max_allowed_packet and characterset inside try catch (and set defaults)
-MySql - fixed problem where socket was not getting closed properly (thanks Steve!)
-
-10/14/2003
-MySql - Fixed problem where ExecuteNonQuery was not always returning the right value
-
-10/13/2003
-MySql - Fixed InternalConnection to not use @@session.max_allowed_packet but use @@max_allowed_packet.  (Thanks Miguel)
-
-10/12/2003
-MySql - Added many new XML doc lines
-
-10/10/2003
-MySql - Fixed sql parsing to not send empty queries (thanks Rory)
-MySql - Fixed problem where the reader was not unpeeking the packet on close
-MySql - Fixed problem where user variables were not being handled (thanks Sami Vaaraniemi)
-MySql - Fixed loop checking in the MySqlPool (thanks Steve M. Brown)
-
-10/7/2003
-MySql - Fixed ParameterCollection.Add method to match SqlClient (thanks Joshua Mouch)
-Common & MySql - Fixed ConnectionSTring parsing to handle no and yes for boolean and not lowercase values (thanks Naucki)
-
-10/3/2003
-MySql - Added InternalConnection class, changes to pooling
-Common - Implemented Persist Security Info
-
-9/26/2003
-Common - Added security.cs and version.cs to project
-
-9/25/2003
-MySql - Fixed DateTime handling in Parameter.cs (thanks Burkhard Perkens-Golomb)
-MySql - Fixed parameter serialization where some types would throw a cast exception
-MySql - Fixed DataReader to convert all returned values to prevent casting errors (thanks Keith Murray)
-MySql - Added code to Command.ExecuteReader to return null if the initial SQL command throws an exception (thanks Burkhard Perkens-Golomb)
-
-9/24/2003
-MySql - Fixed ExecuteScalar bug introduced with restructure
-
-9/23/2003
-MySql - Restructure to allow for LOCAL DATA INFILE and better sequencing of packets
-MySql - Fixed several bugs related to restructure.
-
-9/10/2003
-MySql - Early work done to support more secure passwords in Mysql 4.1.  Old passwords in 4.1 not supported yet
-
-8/22/2003
-MySql- Parameters appearing after system parameters are now handled correctly (Adam M. (adammil))
-MySql - strings can now be assigned directly to blob fields (Adam M.)
-
-8/20/2003
-MySql - Fixed float parameters (thanks Pent)
-
-8/7/2003
-MySql - Improved Parameter ctor and ParameterCollection.Add methods to better match SqlClient (thx Joshua Mouch )
-MySql - Corrected Connection.CreateCommand to return a MySqlCommand type
-MySql - Fixed connection string designer dialog box problem (thanks Abraham Guyt)
-
-7/24/2003
-MySql - Fixed problem with sending commands not always reading the response packet (thanks Joshua Mouch )
-MySql - Fixed parameter serialization where some blobs types were not being handled (thanks Sean McGinnis )
-
-7/22/2003
-MySql - Removed spurious MessageBox.show from DataReader code (thanks Joshua Mouch )
-
-7/17/2003
-MySql - Fixed a nasty bug in the split sql code (thanks everyone! :-) )
-
-*************Released 0.71***********************
-7/15/2003
-MySql - Fixed bug in MySqlStream where too much data could attempt to be read (thanks Peter Belbin)
-
-7/11/2003
-MySql - Implemented HasRows (thanks Nash Pherson)
-MySql - Fixed bug where tables with more than 252 columns cause an exception ( thanks Joshua Kessler )
-MySql - Fixed bug where SQL statements ending in ; would cause a problem ( thanks Shane Krueger )
-MySql - Fixed bug in driver where error messsages were getting truncated by 1 character (thanks Shane Krueger)
-
-7/6/2003
-========MySql===============
-* Made MySqlException serializable (thanks Mathias Hasselmann)
-
-========PgSql===============
-* Made PgSqlException serializable (thanks Mathias Hasselmann)
-
-***********Released 0.70*********************
-
-6/25/2003
-========MySql===============
-* Updated some of the character code pages to be more accurate
-* Fixed problem where readers could be opened on connections that had readers open
-* Release of 0.70
-
-6/20/2003
-========MySql===============
-* Moved test to separate assembly MySqlClientTests
-
-6/19/2003
-========MySql===============
-* Fixed stupid problem in driver with sequence out of order (Thanks Peter Belbin)
-
-6/18/2003
-========MySql===============
-* Added some pipe tests
-* Increased default max pool size to 50
-* Compiles with Mono 0-24
-
-6/17/2003
-========MySql===============
-* Fixed connection and data reader dispose problems
-* Added String datatype handling to parameter serialization
-
-6/13/2003
-========MySql===============
-* Fixed sequence problem in driver that occured after thrown exception
-  (thanks Burkhard Perkens-Golomb)
-
-6/10/2003
-========MySql===============
-* Added support for CommandBehavior.SingleRow to DataReader
-* Fixed command sql processing so quotes are better handled (thanks Theo Spears)
-
-6/9/2003
-========MySQL===============
-* Fixed parsing of double, single, and decimal values to account for non-English separators.
-  You still have to use the right syntax if you using hard coded sql, but if you use parameters
-  the code will convert floating point types to use '.' appropriately internal both into the server
-  and out.
-  [ Thanks anonymous ]
-* Added MySqlStream class to simplify timeOuts and driver coding.
-* Fixed DataReader so that it is closed properly when the associated connection is closed.  
-  [thanks smishra]
-* Made client more SqlClient compliant so that DataReaders have to be closed before the connection
-  can be used to run another command
-* Improved DBNull.Value handling in the fields
-* Added several unit tests
-* Fixed MySqlException so that the base class is actually called  :-o
-* Improved driver coding
-
-=============PgSql=================
-* Too many changes to document. Still basic structuring of driver.  Driver not really usable yet.
-
-
-
-5/28/2003
-* Fixed bug where NextResult was returning false on the last resultset
-* Added more tests for MySQL
-* Improved casting problems by equating unsigned 32bit values to Int64 and usigned 16bit values to Int32, etc
-
-5/6/2003
-* Added new ctor for MySqlParameter for (name, type, size, srccol)
-* Fixed bug in MySqlDataReader where it didn't check for null fieldlist before returning field count
-
-4/23/2003
-* Started adding MySqlClient unit tests (added MySqlClient/Tests folder and some test cases)
-* Fixed some things in Connection String handling
-
-4/7/2003
-* Moved INIT_DB to MySqlPool.  I may move it again, this is in preparation of the conference.
-
-4/6/2003
-* Fixed bug inside CommandBuilder that prevented inserts from happening properly
-* Reworked some of the internals so that all three execute methods of Command worked properly
-* FIxed many small bugs found during benchmarking
-
-4/5/2003
-* The first cut of CoonectionPooling is working. "min pool size" and "max pool size" are respected.
-
-4/3/2003
-* Work to enable multiple resultsets to be returned
-* Character sets are handled much more intelligently now.  The driver queries MySQL at startup for the default character set.
-  That character set is then used for conversions if that code page can be loaded.  If not, then the default code
-  page for the current OS is used.  
-
-3/31/2003
-* Added code to save the inferred type in the name,value ctor of Parameter
-* Also, inferred type if value of null parameter is changed using Value property
-* Converted all files to use proper Camel case.  MySQL is now MySql in all files.  PgSQL is now PgSql
-* Added attribute to PgSql code to prevent designer from trying to show
-
-3/17/2003
-* Added MySQLDbType property to Parameter object and added proper conversion code to convert from DbType to MySQLDbType)
-* Removed unused ObjectToString method from MySQLParameter.cs
-* Fixed Add(..) method in ParameterCollection so that it doesn't use Add(name, value) instead.
-* Fixed IndexOf and Contains in ParameterCollection to be aware that parameter names are now stored without @ 
-* Fixed Command.ConvertSQLToBytes so it only allows characters that can be in MySQL variable names
-* Fixed DataReader and Field so that blob fields read their data from Field.cs and GetBytes works right
-* Added simple query builder editor to CommandText property of MySQLCommand
-* Fixed CommandBuilder and Parameter serialization to account for Parameters not storing @ in their names
-* Removed MySQLFieldType enum from Field.cs.  Now using MySQLDbType enum
-
-3/15/2003
-* Added Designer attribute to several classes to prevent designer view when using VS.Net
-
-3/13/2003
-* Fixed Initial catalog typo in ConnectionString designer
-* Removed 3 parameter ctor for MySQLParameter that conflicted with (name, type, value)
-* changed MySQLParameter so paramName is now stored without leading @ (this fixed null inserts when using designer)
-* Changed TypeConverter for MySQLParameter to use the ctor with all properties
-
-0.68
-========================================================================
-Note that this build has not been checked out with Mono.  
-
-3/10/2003
-* Fixed sequence issue in driver
-
-3/9/2003
-* Added DbParametersEditor to make parameter editing more like SqlClient
-* Fixed Command class so that parameters can be edited using the designer
-
-3/7/2003
-* Update connection string designer to support Use Compression flag
-
-2/15/2003
-* Fixed string encoding so that European characters like Ã¤ will work correctly
-
-2/9/2003
-* Creating base classes to aid in building new data providers
-* Added support for UID key in connection string
-
-2/10/2003
-* Field, parameter, command now using DBNull.Value instead of null
-* CommandBuilder using DBNull.Value
-* CommandBuilder now builds insert command correctly when an auto_insert field is not present
-* Field now uses typeof keyword to return System.Types (performance)
-
-0.65
-====================
-* MySQLCommandBuilder now implemented
-* Transaction support now implemented (not all table types support this)
-* GetSchemaTable fixed to not use xsd (for Mono)
-* Driver is now Mono-compatible!!
-* TIME data type now supported
-* More work to improve Timestamp data type handling
-* Changed signatures of all classes to match corresponding SqlClient classes
-
-0.60
-======================
-* Protocol compression  using SharpZipLib (www.icsharpcode.net)
-* Named pipes on Windows now working properly
-* Work done to improve Timestamp data type handling
-* Implemented IEnumerable on DataReader so DataGrid would work
-0.50
-======================
-* Speed increased dramatically by removing bugging network sync code
-* Driver no longer buffers rows of data (more ADO.Net compliant)
-* Conversion bugs related to TIMESTAMP and DATETIME fields fixed
+3/11/2004\r
+MySql - Changed command editor to point to MySqlClient.Design\r
+\r
+3/4/2004\r
+Common - Fixed bug in Version.isAtLeast\r
+Common - Changed DBConnectionString to support changes done to MySqlConnectionString\r
+Common - Removed SqlCommandEditor and DataAdapterPreviewDialog\r
+\r
+3/3/2004\r
+MySql - Using new long return values in many places\r
+MySql - Integrated new CompressedStream class\r
+\r
+3/2/2004\r
+MySql - Changed ConnectionString and added attributes to allow it to be used in MySqlClient.Design\r
+MySql - Changed packet.cs to support newer lengths in ReadLenInteger\r
+MySql - changed other classes to use new properties and fields of MySqlConnectionString\r
+MySql - ConnectionInternal is now using PING to see if the server is alive\r
+\r
+3/1/2004\r
+MySql - Moved toolbox bitmaps into resource/\r
+MySql - Changed field.cs to allow values to come directly from row buffer\r
+\r
+2/25/2004\r
+MySql - Changed to use the new driver.Send syntax\r
+MySql - Using a new packet queueing system\r
+MySql - started work handling the "broken" compression packet handling\r
+\r
+2/20/2004\r
+Common - Fixed bug in StreamCreator where failure to connect to a host would continue\r
+to loop infinitly (thanks Kevin Casella)\r
+\r
+2/8/2004\r
+MySql - Improved connectstring handling\r
+MySql - Moved designers into Pro product\r
+\r
+2/4/2004\r
+MySql - Removed some old commented out code from command.cs\r
+MySql - Fixed a problem with compression\r
+\r
+2/2/2004\r
+MySql - Fixed connection object where an exception throw prior to the connection opening would not leave\r
+        the connection in the connecting state (thanks Chris Cline )\r
+\r
+1/31/2004\r
+MySql - Added GUID support\r
+MySql - Fixed sequence out of order bug (thanks Mark Reay)\r
+\r
+1/26/2004\r
+MySql - Enum values now supported as parameter values (thanks Philipp Sumi)\r
+1/22/2004\r
+MySql - Year datatype now supported\r
+\r
+1/21/2004\r
+MySql - fixed compression\r
+\r
+1/20/2004\r
+MySql - Fixed bug where a parameter with a TimeSpan as the value would not serialize properly\r
+MySql,Common - Fixed bug where default ctor would not set default connection string values\r
+MySql - Added some XML comments to some members\r
+MySql - Work to fix/improve compression handling\r
+\r
+1/13/2004\r
+MySql,Common - Improved ConnectionString handling so that it better matches the standard set by SqlClient.\r
+MySql - A MySqlException is now thrown if a username is not included in the connection string\r
+MySql- Localhost is now used as the default if not specified on the connection string\r
+MySql - An exception is now thrown if an attempt is made to set the connection string while the connection is open\r
+MySql - Small changes to ConnectionString docs\r
+MySql,common - Removed MultiHostStream and MySqlStream.  Replaced it with Common/StreamCreator\r
+MySql - Added support for Use Pipe connection string value\r
+MySql - Added Platform class for easier access to platform utility functions\r
+MySql - Fixed small pooling bug where new connection was not getting created after IsAlive fails\r
+Common - Added Platform.cs and StreamCreator.cs\r
+\r
+12/30/2003\r
+MySql - Fixed Field.cs to properly handle 4.1 style timestamps\r
+MySql - Changed Common.Version to Common.DBVersion to avoid name conflict\r
+\r
+\r
+12/29/2003\r
+MySql - Fixed field.cs so that text columns return the right field type (thanks beni27@gmx.net)\r
+\r
+12/22/2003\r
+MySql - Added MySqlError class to provide some reference for error codes (thanks Geert Veenstra)\r
+\r
+------------0.74 ------------------------\r
+\r
+12/6/2003\r
+MySql - Added Unix socket support (thanks Mohammad DAMT [md@mt.web.id])\r
+\r
+12/4/2003\r
+MySql - only calling Thread.Sleep when no data is available\r
+MySql - improved escaping of quote characters in parameter data\r
+MySql - removed misleading comments from parameter.cs\r
+\r
+12/1/2003\r
+Mysql -fixed pooling bug\r
+MySql - same pooling bug fixed again!!  ;-)\r
+\r
+11/30/2003\r
+MySql - Fixed ConnectionSTring editor dialog (thanks marco p (pomarc))\r
+Common - UserId now supported in connection strings (thanks Jeff Neeley)\r
+MySql - Attempting to create a parameter that is not input throws an exception (thanks Ryan Gregg)\r
+\r
+11/29/2003 \r
+MySql - Added much documentation\r
+\r
+11/26/2003\r
+MySql - checked in new MultiHostStream capability.  Big thanks to Dan Guisinger for this.  he originally submitted the code and idea of supporting multiple machines on the connect string.\r
+\r
+11/25/2003\r
+MySql - Added alot of documentation.  Still alot to do.\r
+\r
+11/24/2003\r
+MySql - Fixed speed issue with 0.73\r
+\r
+11/14/2003\r
+MySql - changed to Thread.Sleep(0) in MySqlDataStream to help optimize the case where it doesn't need to wait (thanks Todd German)\r
+11/1/2003\r
+MySql - Prepopulating the idlepools to MinPoolSize\r
+\r
+10/31/2003\r
+MySql - Fixed MySqlPool deadlock condition as well as stupid bug where CreateNewPooledConnection\r
+        was not ever adding new connections to the pool.\r
+       Also fixed MySqlStream.ReadBytes and ReadByte to not use TicksPerSecond which does not appear\r
+       to always be right.\r
+       (thanks Matthew J. Peddlesden)\r
+MySql - Fix for precision and scale (thanks Matthew J. Peddlesden)\r
+\r
+10/28/2003\r
+MySql - Added Thread.Sleep(1) to stream reading methods to be more cpu friendly (thanks Sean McGinnis)\r
+\r
+10/24/2003\r
+MySql - Fixed problem where ExecuteReader would sometime return null (thanks Lloyd Dupont )\r
+\r
+10/17/2003\r
+MySql - Fixed major bug with null field handling (thanks Naucki)\r
+\r
+10/15/2003\r
+MySql - enclosed queries for max_allowed_packet and characterset inside try catch (and set defaults)\r
+MySql - fixed problem where socket was not getting closed properly (thanks Steve!)\r
+\r
+10/14/2003\r
+MySql - Fixed problem where ExecuteNonQuery was not always returning the right value\r
+\r
+10/13/2003\r
+MySql - Fixed InternalConnection to not use @@session.max_allowed_packet but use @@max_allowed_packet.  (Thanks Miguel)\r
+\r
+10/12/2003\r
+MySql - Added many new XML doc lines\r
+\r
+10/10/2003\r
+MySql - Fixed sql parsing to not send empty queries (thanks Rory)\r
+MySql - Fixed problem where the reader was not unpeeking the packet on close\r
+MySql - Fixed problem where user variables were not being handled (thanks Sami Vaaraniemi)\r
+MySql - Fixed loop checking in the MySqlPool (thanks Steve M. Brown)\r
+\r
+10/7/2003\r
+MySql - Fixed ParameterCollection.Add method to match SqlClient (thanks Joshua Mouch)\r
+Common & MySql - Fixed ConnectionSTring parsing to handle no and yes for boolean and not lowercase values (thanks Naucki)\r
+\r
+10/3/2003\r
+MySql - Added InternalConnection class, changes to pooling\r
+Common - Implemented Persist Security Info\r
+\r
+9/26/2003\r
+Common - Added security.cs and version.cs to project\r
+\r
+9/25/2003\r
+MySql - Fixed DateTime handling in Parameter.cs (thanks Burkhard Perkens-Golomb)\r
+MySql - Fixed parameter serialization where some types would throw a cast exception\r
+MySql - Fixed DataReader to convert all returned values to prevent casting errors (thanks Keith Murray)\r
+MySql - Added code to Command.ExecuteReader to return null if the initial SQL command throws an exception (thanks Burkhard Perkens-Golomb)\r
+\r
+9/24/2003\r
+MySql - Fixed ExecuteScalar bug introduced with restructure\r
+\r
+9/23/2003\r
+MySql - Restructure to allow for LOCAL DATA INFILE and better sequencing of packets\r
+MySql - Fixed several bugs related to restructure.\r
+\r
+9/10/2003\r
+MySql - Early work done to support more secure passwords in Mysql 4.1.  Old passwords in 4.1 not supported yet\r
+\r
+8/22/2003\r
+MySql- Parameters appearing after system parameters are now handled correctly (Adam M. (adammil))\r
+MySql - strings can now be assigned directly to blob fields (Adam M.)\r
+\r
+8/20/2003\r
+MySql - Fixed float parameters (thanks Pent)\r
+\r
+8/7/2003\r
+MySql - Improved Parameter ctor and ParameterCollection.Add methods to better match SqlClient (thx Joshua Mouch )\r
+MySql - Corrected Connection.CreateCommand to return a MySqlCommand type\r
+MySql - Fixed connection string designer dialog box problem (thanks Abraham Guyt)\r
+\r
+7/24/2003\r
+MySql - Fixed problem with sending commands not always reading the response packet (thanks Joshua Mouch )\r
+MySql - Fixed parameter serialization where some blobs types were not being handled (thanks Sean McGinnis )\r
+\r
+7/22/2003\r
+MySql - Removed spurious MessageBox.show from DataReader code (thanks Joshua Mouch )\r
+\r
+7/17/2003\r
+MySql - Fixed a nasty bug in the split sql code (thanks everyone! :-) )\r
+\r
+*************Released 0.71***********************\r
+7/15/2003\r
+MySql - Fixed bug in MySqlStream where too much data could attempt to be read (thanks Peter Belbin)\r
+\r
+7/11/2003\r
+MySql - Implemented HasRows (thanks Nash Pherson)\r
+MySql - Fixed bug where tables with more than 252 columns cause an exception ( thanks Joshua Kessler )\r
+MySql - Fixed bug where SQL statements ending in ; would cause a problem ( thanks Shane Krueger )\r
+MySql - Fixed bug in driver where error messsages were getting truncated by 1 character (thanks Shane Krueger)\r
+\r
+7/6/2003\r
+========MySql===============\r
+* Made MySqlException serializable (thanks Mathias Hasselmann)\r
+\r
+========PgSql===============\r
+* Made PgSqlException serializable (thanks Mathias Hasselmann)\r
+\r
+***********Released 0.70*********************\r
+\r
+6/25/2003\r
+========MySql===============\r
+* Updated some of the character code pages to be more accurate\r
+* Fixed problem where readers could be opened on connections that had readers open\r
+* Release of 0.70\r
+\r
+6/20/2003\r
+========MySql===============\r
+* Moved test to separate assembly MySqlClientTests\r
+\r
+6/19/2003\r
+========MySql===============\r
+* Fixed stupid problem in driver with sequence out of order (Thanks Peter Belbin)\r
+\r
+6/18/2003\r
+========MySql===============\r
+* Added some pipe tests\r
+* Increased default max pool size to 50\r
+* Compiles with Mono 0-24\r
+\r
+6/17/2003\r
+========MySql===============\r
+* Fixed connection and data reader dispose problems\r
+* Added String datatype handling to parameter serialization\r
+\r
+6/13/2003\r
+========MySql===============\r
+* Fixed sequence problem in driver that occured after thrown exception\r
+  (thanks Burkhard Perkens-Golomb)\r
+\r
+6/10/2003\r
+========MySql===============\r
+* Added support for CommandBehavior.SingleRow to DataReader\r
+* Fixed command sql processing so quotes are better handled (thanks Theo Spears)\r
+\r
+6/9/2003\r
+========MySQL===============\r
+* Fixed parsing of double, single, and decimal values to account for non-English separators.\r
+  You still have to use the right syntax if you using hard coded sql, but if you use parameters\r
+  the code will convert floating point types to use '.' appropriately internal both into the server\r
+  and out.\r
+  [ Thanks anonymous ]\r
+* Added MySqlStream class to simplify timeOuts and driver coding.\r
+* Fixed DataReader so that it is closed properly when the associated connection is closed.  \r
+  [thanks smishra]\r
+* Made client more SqlClient compliant so that DataReaders have to be closed before the connection\r
+  can be used to run another command\r
+* Improved DBNull.Value handling in the fields\r
+* Added several unit tests\r
+* Fixed MySqlException so that the base class is actually called  :-o\r
+* Improved driver coding\r
+\r
+=============PgSql=================\r
+* Too many changes to document. Still basic structuring of driver.  Driver not really usable yet.\r
+\r
+\r
+\r
+5/28/2003\r
+* Fixed bug where NextResult was returning false on the last resultset\r
+* Added more tests for MySQL\r
+* Improved casting problems by equating unsigned 32bit values to Int64 and usigned 16bit values to Int32, etc\r
+\r
+5/6/2003\r
+* Added new ctor for MySqlParameter for (name, type, size, srccol)\r
+* Fixed bug in MySqlDataReader where it didn't check for null fieldlist before returning field count\r
+\r
+4/23/2003\r
+* Started adding MySqlClient unit tests (added MySqlClient/Tests folder and some test cases)\r
+* Fixed some things in Connection String handling\r
+\r
+4/7/2003\r
+* Moved INIT_DB to MySqlPool.  I may move it again, this is in preparation of the conference.\r
+\r
+4/6/2003\r
+* Fixed bug inside CommandBuilder that prevented inserts from happening properly\r
+* Reworked some of the internals so that all three execute methods of Command worked properly\r
+* FIxed many small bugs found during benchmarking\r
+\r
+4/5/2003\r
+* The first cut of CoonectionPooling is working. "min pool size" and "max pool size" are respected.\r
+\r
+4/3/2003\r
+* Work to enable multiple resultsets to be returned\r
+* Character sets are handled much more intelligently now.  The driver queries MySQL at startup for the default character set.\r
+  That character set is then used for conversions if that code page can be loaded.  If not, then the default code\r
+  page for the current OS is used.  \r
+\r
+3/31/2003\r
+* Added code to save the inferred type in the name,value ctor of Parameter\r
+* Also, inferred type if value of null parameter is changed using Value property\r
+* Converted all files to use proper Camel case.  MySQL is now MySql in all files.  PgSQL is now PgSql\r
+* Added attribute to PgSql code to prevent designer from trying to show\r
+\r
+3/17/2003\r
+* Added MySQLDbType property to Parameter object and added proper conversion code to convert from DbType to MySQLDbType)\r
+* Removed unused ObjectToString method from MySQLParameter.cs\r
+* Fixed Add(..) method in ParameterCollection so that it doesn't use Add(name, value) instead.\r
+* Fixed IndexOf and Contains in ParameterCollection to be aware that parameter names are now stored without @ \r
+* Fixed Command.ConvertSQLToBytes so it only allows characters that can be in MySQL variable names\r
+* Fixed DataReader and Field so that blob fields read their data from Field.cs and GetBytes works right\r
+* Added simple query builder editor to CommandText property of MySQLCommand\r
+* Fixed CommandBuilder and Parameter serialization to account for Parameters not storing @ in their names\r
+* Removed MySQLFieldType enum from Field.cs.  Now using MySQLDbType enum\r
+\r
+3/15/2003\r
+* Added Designer attribute to several classes to prevent designer view when using VS.Net\r
+\r
+3/13/2003\r
+* Fixed Initial catalog typo in ConnectionString designer\r
+* Removed 3 parameter ctor for MySQLParameter that conflicted with (name, type, value)\r
+* changed MySQLParameter so paramName is now stored without leading @ (this fixed null inserts when using designer)\r
+* Changed TypeConverter for MySQLParameter to use the ctor with all properties\r
+\r
+0.68\r
+========================================================================\r
+Note that this build has not been checked out with Mono.  \r
+\r
+3/10/2003\r
+* Fixed sequence issue in driver\r
+\r
+3/9/2003\r
+* Added DbParametersEditor to make parameter editing more like SqlClient\r
+* Fixed Command class so that parameters can be edited using the designer\r
+\r
+3/7/2003\r
+* Update connection string designer to support Use Compression flag\r
+\r
+2/15/2003\r
+* Fixed string encoding so that European characters like Ã¤ will work correctly\r
+\r
+2/9/2003\r
+* Creating base classes to aid in building new data providers\r
+* Added support for UID key in connection string\r
+\r
+2/10/2003\r
+* Field, parameter, command now using DBNull.Value instead of null\r
+* CommandBuilder using DBNull.Value\r
+* CommandBuilder now builds insert command correctly when an auto_insert field is not present\r
+* Field now uses typeof keyword to return System.Types (performance)\r
+\r
+0.65\r
+====================\r
+* MySQLCommandBuilder now implemented\r
+* Transaction support now implemented (not all table types support this)\r
+* GetSchemaTable fixed to not use xsd (for Mono)\r
+* Driver is now Mono-compatible!!\r
+* TIME data type now supported\r
+* More work to improve Timestamp data type handling\r
+* Changed signatures of all classes to match corresponding SqlClient classes\r
+\r
+0.60\r
+======================\r
+* Protocol compression  using SharpZipLib (www.icsharpcode.net)\r
+* Named pipes on Windows now working properly\r
+* Work done to improve Timestamp data type handling\r
+* Implemented IEnumerable on DataReader so DataGrid would work\r
\r
+0.50\r
+======================\r
+* Speed increased dramatically by removing bugging network sync code\r
+* Driver no longer buffers rows of data (more ADO.Net compliant)\r
+* Conversion bugs related to TIMESTAMP and DATETIME fields fixed\r
index b3ecbf4cd8ea43e48e24885fe24bcab80f892264..41beb43d085f407ac0b454c3aa027d4c89b5e17c 100755 (executable)
@@ -1,53 +1,53 @@
-using System;
-using System.IO;
-
-namespace ByteFX.Data.Common
-{
-       /// <summary>
-       /// Summary description for BitStream.
-       /// </summary>
-       public class BitStream : MemoryStream
-       {
-               private byte[]  _input;
-               private int             _start;
-               private int             _end;
-               private int             _bitindex;
-               private uint    _bitbuffer;
-               private int             _bits_in_buffer;
-
-               public BitStream(byte[] input, int index, int len)
-               {
-                       _bitindex = 0;
-                       _bitbuffer = 0;
-                       _bits_in_buffer = 0;
-                       _input = input;
-                       _start = index;
-                       _end = _start + len;
-               }
-
-               public int GetBits(int numbits)
-               {
-                       return 0;
-               }
-
-               public int PeekBits(int numbits)
-               {
-                       int val=0;
-
-                       int index=_start;
-                       while (numbits > 0)
-                       {
-                               val = (val << 8) | _input[index++];
-                               numbits -= 8;
-                       }
-
-                       while (_bits_in_buffer < numbits)
-                       {
-                               if (_start == _end)
-                                       throw new Exception("Out of bits");
-                               byte b = _input[_start++];
-                       }
-                       return 0;
-               }
-       }
-}
+using System;\r
+using System.IO;\r
+\r
+namespace ByteFX.Data.Common\r
+{\r
+       /// <summary>\r
+       /// Summary description for BitStream.\r
+       /// </summary>\r
+       public class BitStream : MemoryStream\r
+       {\r
+               private byte[]  _input;\r
+               private int             _start;\r
+               private int             _end;\r
+               private int             _bitindex;\r
+               private uint    _bitbuffer;\r
+               private int             _bits_in_buffer;\r
+\r
+               public BitStream(byte[] input, int index, int len)\r
+               {\r
+                       _bitindex = 0;\r
+                       _bitbuffer = 0;\r
+                       _bits_in_buffer = 0;\r
+                       _input = input;\r
+                       _start = index;\r
+                       _end = _start + len;\r
+               }\r
+\r
+               public int GetBits(int numbits)\r
+               {\r
+                       return 0;\r
+               }\r
+\r
+               public int PeekBits(int numbits)\r
+               {\r
+                       int val=0;\r
+\r
+                       int index=_start;\r
+                       while (numbits > 0)\r
+                       {\r
+                               val = (val << 8) | _input[index++];\r
+                               numbits -= 8;\r
+                       }\r
+\r
+                       while (_bits_in_buffer < numbits)\r
+                       {\r
+                               if (_start == _end)\r
+                                       throw new Exception("Out of bits");\r
+                               byte b = _input[_start++];\r
+                       }\r
+                       return 0;\r
+               }\r
+       }\r
+}\r
index 6b90a7a5d79ebf01fda19b297558a36961cc6353..a6c25b4a10ec5c1f98f87c7a33918348913ea943 100755 (executable)
-// ByteFX.Data data access components for .Net
-// Copyright (C) 2002-2003  ByteFX, Inc.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// 
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-// 
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-using System;
-using System.ComponentModel;
-using System.Collections.Specialized;
-using System.Data;
-
-namespace ByteFX.Data.Common
-{
-       /// <summary>
-       /// Summary description for Connection.
-       /// </summary>
-       [ToolboxItem(false)]
-       [System.ComponentModel.DesignerCategory("Code")]
-       public class Connection : Component
-       {
-               internal ConnectionString       connString;
-               internal ConnectionState        state;
-               internal IDataReader            reader = null;
-
-
-               public Connection(System.ComponentModel.IContainer container)
-               {
-                       /// <summary>
-                       /// Required for Windows.Forms Class Composition Designer support
-                       /// </summary>
-                       container.Add(this);
-                       Init();
-               }
-
-               public Connection()
-               {
-                       Init();
-               }
-
-               protected void Init() 
-               {
-                       state = ConnectionState.Closed;
-               }
-
-
-               [Browsable(true)]
-               public string DataSource
-               {
-                       get
-                       {
-                               String s = connString["data source"];
-                               if (s == null || s.Length == 0)
-                                       return "localhost";
-                               return s;
-                       }
-               }
-
-               [Browsable(false)]
-               public string User
-               {
-                       get
-                       {
-                               string s = connString["user id"];
-                               if (s == null)
-                                       s = "";
-                               return s;
-                       }
-               }
-
-               [Browsable(false)]
-               public string Password
-               {
-                       get
-                       {
-                               string pwd = connString["password"];
-                               if (pwd == null)
-                                       pwd = "";
-                               return pwd;
-                       }
-               }
-
-               [Browsable(true)]
-               public int ConnectionTimeout
-               {
-                       get
-                       {
-                               // Returns the connection time-out value set in the connection
-                               // string. Zero indicates an indefinite time-out period.
-                               if (connString == null)
-                                       return 30;
-                               return connString.GetIntOption("connection timeout", 30);
-                       }
-               }
-               
-               [Browsable(true)]
-               public string Database
-               {
-                       get     
-                       {       
-                               // Returns an initial database as set in the connection string.
-                               // An empty string indicates not set - do not return a null reference.
-                               return connString["database"];
-                       }
-               }
-
-               [Browsable(false)]
-               public ConnectionState State
-               {
-                       get { return state; }
-               }
-
-               internal IDataReader Reader
-               {
-                       get { return reader; }
-                       set { reader = value; }
-               }
-       }
-}
+// ByteFX.Data data access components for .Net\r
+// Copyright (C) 2002-2003  ByteFX, Inc.\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License, or (at your option) any later version.\r
+// \r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+// Lesser General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+\r
+using System;\r
+using System.ComponentModel;\r
+using System.Collections.Specialized;\r
+using System.Data;\r
+\r
+namespace ByteFX.Data.Common\r
+{\r
+       /// <summary>\r
+       /// Summary description for Connection.\r
+       /// </summary>\r
+       [ToolboxItem(false)]\r
+       [System.ComponentModel.DesignerCategory("Code")]\r
+       public class Connection : Component\r
+       {\r
+               internal ConnectionString       connString;\r
+               internal ConnectionState        state;\r
+               internal IDataReader            reader = null;\r
+\r
+\r
+               public Connection(System.ComponentModel.IContainer container)\r
+               {\r
+                       /// <summary>\r
+                       /// Required for Windows.Forms Class Composition Designer support\r
+                       /// </summary>\r
+                       container.Add(this);\r
+                       Init();\r
+               }\r
+\r
+               public Connection()\r
+               {\r
+                       Init();\r
+               }\r
+\r
+               protected void Init() \r
+               {\r
+                       state = ConnectionState.Closed;\r
+               }\r
+\r
+\r
+               [Browsable(true)]\r
+               public string DataSource\r
+               {\r
+                       get\r
+                       {\r
+                               String s = connString["data source"];\r
+                               if (s == null || s.Length == 0)\r
+                                       return "localhost";\r
+                               return s;\r
+                       }\r
+               }\r
+\r
+               [Browsable(false)]\r
+               public string User\r
+               {\r
+                       get\r
+                       {\r
+                               string s = connString["user id"];\r
+                               if (s == null)\r
+                                       s = "";\r
+                               return s;\r
+                       }\r
+               }\r
+\r
+               [Browsable(false)]\r
+               public string Password\r
+               {\r
+                       get\r
+                       {\r
+                               string pwd = connString["password"];\r
+                               if (pwd == null)\r
+                                       pwd = "";\r
+                               return pwd;\r
+                       }\r
+               }\r
+\r
+               [Browsable(true)]\r
+               public int ConnectionTimeout\r
+               {\r
+                       get\r
+                       {\r
+                               // Returns the connection time-out value set in the connection\r
+                               // string. Zero indicates an indefinite time-out period.\r
+                               if (connString == null)\r
+                                       return 30;\r
+                               return connString.GetIntOption("connection timeout", 30);\r
+                       }\r
+               }\r
+               \r
+               [Browsable(true)]\r
+               public string Database\r
+               {\r
+                       get     \r
+                       {       \r
+                               // Returns an initial database as set in the connection string.\r
+                               // An empty string indicates not set - do not return a null reference.\r
+                               return connString["database"];\r
+                       }\r
+               }\r
+\r
+               [Browsable(false)]\r
+               public ConnectionState State\r
+               {\r
+                       get { return state; }\r
+               }\r
+\r
+               internal IDataReader Reader\r
+               {\r
+                       get { return reader; }\r
+                       set { reader = value; }\r
+               }\r
+       }\r
+}\r
index b4bc6cf20d0fe754768ec9fd0268de99245a0696..263923effed2c64de508215c4d464904702e217a 100755 (executable)
-// ByteFX.Data data access components for .Net
-// Copyright (C) 2002-2003  ByteFX, Inc.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// 
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-// 
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-using System;
-using System.Collections.Specialized;
-
-namespace ByteFX.Data.Common
-{
-       /// <summary>
-       /// Summary description for Utility.
-       /// </summary>
-       internal class ConnectionString
-       {
-               private StringDictionary        elements;
-               private string                          connString;
-
-               public ConnectionString(string connString)
-               {
-                       this.connString = connString;
-                       elements = new StringDictionary();
-                       Parse( connString );
-               }
-
-               public string Value
-               {
-                       get { return connString; }
-               }
-
-               public string this[string key] 
-               {
-                       get 
-                       { 
-                               string val = elements[key];
-                               return val;
-                       }
-               }
-
-               public int  GetIntOption( string key, int defaultvalue ) 
-               {
-                       string val = this[ key ];
-                       if (null == val) return defaultvalue;
-                       return Convert.ToInt32( val );
-               }
-
-               public bool  GetBoolOption( string key, bool defaultvalue ) 
-               {
-                       string val = this[ key ];
-                       if (null == val) return defaultvalue;
-                       val = val.ToLower();
-                       if (val == "true" || val == "yes") return true;
-                       return false;
-               }
-
-               public bool Contains( string key ) 
-               {
-                       return elements.ContainsKey(key);
-               }
-
-               public bool Equals( ConnectionString obj ) 
-               {
-                       foreach (string key in elements.Keys) 
-                       {
-                               if (! obj.Contains(key)) return false;
-                               if ( ! this[key].Equals( obj[key] )) return false;
-                       }
-                       return true;
-               }
-
-               /// <summary>
-               /// 
-               /// </summary>
-               /// <param name="obj"></param>
-               /// <returns></returns>
-               public bool PoolingEquals( ConnectionString obj ) 
-               {
-                       foreach (string key in elements.Keys) 
-                       {
-                               // these connection string elements only affect pooling
-                               // so we don't check them when making sure connection strings
-                               // are alike
-                               if (key.Equals("connection lifetime")) continue;
-                               if (key.Equals("connection reset")) continue;
-                               if (key.Equals("enlist")) continue;
-                               if (key.Equals("max pool size")) continue;
-                               if (key.Equals("min pool size")) continue;
-                               if (key.Equals("pooling")) continue;
-
-                               if (! obj.Contains(key)) return false;
-                               if ( ! this[key].Equals( obj[key] )) return false;
-                       }
-                       return true;
-               }
-
-               /// <summary>
-               /// 
-               /// </summary>
-               /// <param name="s"></param>
-               public void Parse( String s ) 
-               {
-                       String[] keyvalues = s.Split( ';' );
-                       String[] newkeyvalues = new String[keyvalues.Length];
-                       int              x = 0;
-
-                       elements.Clear();
-
-                       // first run through the array and check for any keys that
-                       // have ; in their value
-                       foreach (String keyvalue in keyvalues) 
-                       {
-                               // check for trailing ; at the end of the connection string
-                               if (keyvalue.Length == 0) continue;
-
-                               // this value has an '=' sign so we are ok
-                               if (keyvalue.IndexOf('=') >= 0) 
-                               {
-                                       newkeyvalues[x++] = keyvalue;
-                               }
-                               else 
-                               {
-                                       newkeyvalues[x-1] += ";";
-                                       newkeyvalues[x-1] += keyvalue;
-                               }
-                       }
-
-                       // now we run through our normalized key-values, splitting on equals
-                       for (int y=0; y < x; y++) 
-                       {
-                               String[] parts = newkeyvalues[y].Split( '=' );
-
-                               // first trim off any space and lowercase the key
-                               parts[0] = parts[0].Trim().ToLower();
-                               parts[1] = parts[1].Trim();
-
-                               // normalize the keys going in.  We want to support the same synonyms that
-                               // SqlClient supports
-                               switch (parts[0]) 
-                               {
-                                       case "uid": parts[0] = "user id"; break;
-                                       case "pwd": parts[0] = "password"; break;
-                                       case "user": parts[0] = "user id"; break;
-                                       case "initial catalog": parts[0] = "database"; break;
-                                       case "server": parts[0] = "data source"; break;
-                               }
-
-                               // we also want to clear off any quotes
-                               String newvalue = parts[1].Trim( '\'' );
-                               if (newvalue.Length == parts[1].Length) 
-                               {
-                                       newvalue = parts[1].Trim('"');
-                               }
-                               parts[1] = newvalue;
-
-                               // make sure we don't get dupliate keys
-                               if (elements.ContainsKey(parts[0])) 
-                               {
-                                       throw new ArgumentException("Duplicate key in connection string", parts[0]);
-                               }
-
-                               elements.Add( parts[0], parts[1] );
-
-                               // now put the correct parsed string into the connection string !! (AG 4/8/2003)
-                               connString="";
-                               foreach(string key in elements.Keys)
-                               {
-                                       connString=connString+key+"="+elements[key]+"; ";
-                               }
-                               connString=connString.Substring(0,connString.Length-2);
-                       }
-               }
-       }
-}
+// ByteFX.Data data access components for .Net\r
+// Copyright (C) 2002-2003  ByteFX, Inc.\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License, or (at your option) any later version.\r
+// \r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+// Lesser General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+\r
+using System;\r
+using System.Collections.Specialized;\r
+\r
+namespace ByteFX.Data.Common\r
+{\r
+       /// <summary>\r
+       /// Summary description for Utility.\r
+       /// </summary>\r
+       internal class ConnectionString\r
+       {\r
+               private StringDictionary        elements;\r
+               private string                          connString;\r
+\r
+               public ConnectionString(string connString)\r
+               {\r
+                       this.connString = connString;\r
+                       elements = new StringDictionary();\r
+                       Parse( connString );\r
+               }\r
+\r
+               public string Value\r
+               {\r
+                       get { return connString; }\r
+               }\r
+\r
+               public string this[string key] \r
+               {\r
+                       get \r
+                       { \r
+                               string val = elements[key];\r
+                               return val;\r
+                       }\r
+               }\r
+\r
+               public int  GetIntOption( string key, int defaultvalue ) \r
+               {\r
+                       string val = this[ key ];\r
+                       if (null == val) return defaultvalue;\r
+                       return Convert.ToInt32( val );\r
+               }\r
+\r
+               public bool  GetBoolOption( string key, bool defaultvalue ) \r
+               {\r
+                       string val = this[ key ];\r
+                       if (null == val) return defaultvalue;\r
+                       val = val.ToLower();\r
+                       if (val == "true" || val == "yes") return true;\r
+                       return false;\r
+               }\r
+\r
+               public bool Contains( string key ) \r
+               {\r
+                       return elements.ContainsKey(key);\r
+               }\r
+\r
+               public bool Equals( ConnectionString obj ) \r
+               {\r
+                       foreach (string key in elements.Keys) \r
+                       {\r
+                               if (! obj.Contains(key)) return false;\r
+                               if ( ! this[key].Equals( obj[key] )) return false;\r
+                       }\r
+                       return true;\r
+               }\r
+\r
+               /// <summary>\r
+               /// \r
+               /// </summary>\r
+               /// <param name="obj"></param>\r
+               /// <returns></returns>\r
+               public bool PoolingEquals( ConnectionString obj ) \r
+               {\r
+                       foreach (string key in elements.Keys) \r
+                       {\r
+                               // these connection string elements only affect pooling\r
+                               // so we don't check them when making sure connection strings\r
+                               // are alike\r
+                               if (key.Equals("connection lifetime")) continue;\r
+                               if (key.Equals("connection reset")) continue;\r
+                               if (key.Equals("enlist")) continue;\r
+                               if (key.Equals("max pool size")) continue;\r
+                               if (key.Equals("min pool size")) continue;\r
+                               if (key.Equals("pooling")) continue;\r
+\r
+                               if (! obj.Contains(key)) return false;\r
+                               if ( ! this[key].Equals( obj[key] )) return false;\r
+                       }\r
+                       return true;\r
+               }\r
+\r
+               /// <summary>\r
+               /// \r
+               /// </summary>\r
+               /// <param name="s"></param>\r
+               public void Parse( String s ) \r
+               {\r
+                       String[] keyvalues = s.Split( ';' );\r
+                       String[] newkeyvalues = new String[keyvalues.Length];\r
+                       int              x = 0;\r
+\r
+                       elements.Clear();\r
+\r
+                       // first run through the array and check for any keys that\r
+                       // have ; in their value\r
+                       foreach (String keyvalue in keyvalues) \r
+                       {\r
+                               // check for trailing ; at the end of the connection string\r
+                               if (keyvalue.Length == 0) continue;\r
+\r
+                               // this value has an '=' sign so we are ok\r
+                               if (keyvalue.IndexOf('=') >= 0) \r
+                               {\r
+                                       newkeyvalues[x++] = keyvalue;\r
+                               }\r
+                               else \r
+                               {\r
+                                       newkeyvalues[x-1] += ";";\r
+                                       newkeyvalues[x-1] += keyvalue;\r
+                               }\r
+                       }\r
+\r
+                       // now we run through our normalized key-values, splitting on equals\r
+                       for (int y=0; y < x; y++) \r
+                       {\r
+                               String[] parts = newkeyvalues[y].Split( '=' );\r
+\r
+                               // first trim off any space and lowercase the key\r
+                               parts[0] = parts[0].Trim().ToLower();\r
+                               parts[1] = parts[1].Trim();\r
+\r
+                               // normalize the keys going in.  We want to support the same synonyms that\r
+                               // SqlClient supports\r
+                               switch (parts[0]) \r
+                               {\r
+                                       case "uid": parts[0] = "user id"; break;\r
+                                       case "pwd": parts[0] = "password"; break;\r
+                                       case "user": parts[0] = "user id"; break;\r
+                                       case "initial catalog": parts[0] = "database"; break;\r
+                                       case "server": parts[0] = "data source"; break;\r
+                               }\r
+\r
+                               // we also want to clear off any quotes\r
+                               String newvalue = parts[1].Trim( '\'' );\r
+                               if (newvalue.Length == parts[1].Length) \r
+                               {\r
+                                       newvalue = parts[1].Trim('"');\r
+                               }\r
+                               parts[1] = newvalue;\r
+\r
+                               // make sure we don't get dupliate keys\r
+                               if (elements.ContainsKey(parts[0])) \r
+                               {\r
+                                       throw new ArgumentException("Duplicate key in connection string", parts[0]);\r
+                               }\r
+\r
+                               elements.Add( parts[0], parts[1] );\r
+\r
+                               // now put the correct parsed string into the connection string !! (AG 4/8/2003)\r
+                               connString="";\r
+                               foreach(string key in elements.Keys)\r
+                               {\r
+                                       connString=connString+key+"="+elements[key]+"; ";\r
+                               }\r
+                               connString=connString.Substring(0,connString.Length-2);\r
+                       }\r
+               }\r
+       }\r
+}\r
index 2fe01655ad4b95bd068335326089e3d0678970dd..06b41be27fe5456281921a858b77cbf0c23bd200 100644 (file)
-// ByteFX.Data data access components for .Net
-// Copyright (C) 2002-2003  ByteFX, Inc.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// 
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-// 
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-using System;
-using System.Collections;
-using System.Text;
-
-namespace ByteFX.Data.Common
-{
-       /// <summary>
-       /// Summary description for Utility.
-       /// </summary>
-       internal class DBConnectionString
-       {
-               protected Hashtable     keyValues = new Hashtable();
-               protected string        connectString;
-               protected string        host;
-               protected string        username;
-               protected string        password;
-               protected string        database;
-               protected int           connectTimeout;
-               protected int           port;
-               protected int           maxPoolSize;
-               protected int           minPoolSize;
-               protected int           connectLifetime;
-               protected bool          pooling;
-               protected bool          persistSecurityInfo;
-
-               public DBConnectionString()
-               {       
-                       persistSecurityInfo = false;
-               }
-
-               public DBConnectionString(string connectString) : this()
-               {
-                       this.connectString = connectString;
-               }
-
-               #region Properties
-               public string Host 
-               {
-                       get { return host; }
-               }
-
-               public string Username 
-               {
-                       get { return username; }
-               }
-
-               public string Password 
-               {
-                       get { return password; }
-               }
-
-               public int ConnectTimeout
-               {
-                       get { return connectTimeout; }
-               }
-               
-               public string Database 
-               {
-                       get { return database; }
-               }
-
-               public int Port 
-               {
-                       get { return port; }
-               }
-
-               public int MaxPoolSize 
-               {
-                       get { return maxPoolSize; }
-               }
-
-               public int MinPoolSize 
-               {
-                       get { return minPoolSize; }
-               }
-
-               public bool Pooling 
-               {
-                       get { return pooling; }
-               }
-
-               public int ConnectionLifetime 
-               {
-                       get { return connectLifetime; }
-               }
-
-               public string ConnectString 
-               {
-                       get { return GetConnectionString(); }
-                       set { connectString = value; Parse(); }
-               }
-
-               #endregion
-
-               private string GetConnectionString()
-               {
-                       StringBuilder str = new StringBuilder();
-
-                       foreach ( string key in keyValues.Keys)
-                       {
-                               if ((key.ToLower() == "pwd" || key.ToLower() == "password") &&
-                                       !persistSecurityInfo) continue;
-                               str.AppendFormat("{0}={1};", key, keyValues[key]);
-                       }
-
-                       if (str.Length > 0)
-                               str.Remove( str.Length-1, 1 );
-
-                       return str.ToString();
-               }
-
-               protected virtual void ConnectionParameterParsed(string key, string value)
-               {
-                       switch (key.ToLower()) 
-                       {
-                               case "persist security info":
-                                       if (value.ToLower() == "no" || value.ToLower() == "false")
-                                               persistSecurityInfo = false;
-                                       else
-                                               persistSecurityInfo = true;
-                                       break;
-
-                               case "uid":
-                               case "username":
-                               case "user id":
-                               case "user name": 
-                               case "userid":
-                                       username = value;
-                                       break;
-
-                               case "password": 
-                               case "pwd":
-                                       password = value;
-                                       break;
-
-                               case "host":
-                               case "server":
-                               case "data source":
-                               case "datasource":
-                               case "address":
-                               case "addr":
-                               case "network address":
-                                       host = value;
-                                       break;
-                               
-                               case "initial catalog":
-                               case "database":
-                                       database = value;
-                                       break;
-
-                               case "connection timeout":
-                               case "connect timeout":
-                                       connectTimeout = Int32.Parse( value );
-                                       break;
-
-                               case "port":
-                                       port = Int32.Parse( value );
-                                       break;
-
-                               case "pooling":
-                                       if (value.ToLower() == "no" || value.ToLower() == "false")
-                                               pooling = false;
-                                       else
-                                               pooling = true;
-                                       break;
-
-                               case "min pool size":
-                                       minPoolSize = Int32.Parse(value);
-                                       break;
-
-                               case "max pool size":
-                                       maxPoolSize = Int32.Parse(value);
-                                       break;
-
-                               case "connection lifetime":
-                                       connectLifetime = Int32.Parse(value);
-                                       break;
-                       }
-               }
-
-               protected void Parse() 
-               {
-                       String[] keyvalues = connectString.Split( ';' );
-                       String[] newkeyvalues = new String[keyvalues.Length];
-                       int              x = 0;
-
-                       // first run through the array and check for any keys that
-                       // have ; in their value
-                       foreach (String keyvalue in keyvalues) 
-                       {
-                               // check for trailing ; at the end of the connection string
-                               if (keyvalue.Length == 0) continue;
-
-                               // this value has an '=' sign so we are ok
-                               if (keyvalue.IndexOf('=') >= 0) 
-                               {
-                                       newkeyvalues[x++] = keyvalue;
-                               }
-                               else 
-                               {
-                                       newkeyvalues[x-1] += ";";
-                                       newkeyvalues[x-1] += keyvalue;
-                               }
-                       }
-
-                       keyValues.Clear();
-
-                       // now we run through our normalized key-values, splitting on equals
-                       for (int y=0; y < x; y++) 
-                       {
-                               String[] parts = newkeyvalues[y].Split( '=' );
-
-                               // first trim off any space and lowercase the key
-                               parts[0] = parts[0].Trim().ToLower();
-                               parts[1] = parts[1].Trim();
-
-                               // we also want to clear off any quotes
-                               parts[0] = parts[0].Trim('\'', '"');
-                               parts[1] = parts[1].Trim('\'', '"');
-
-                               ConnectionParameterParsed( parts[0], parts[1] );
-                               keyValues.Add( parts[0], parts[1] );
-                       }
-               }
-
-
-       }
-}
+// ByteFX.Data data access components for .Net\r
+// Copyright (C) 2002-2003  ByteFX, Inc.\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License, or (at your option) any later version.\r
+// \r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+// Lesser General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+\r
+using System;\r
+using System.Collections;\r
+using System.Text;\r
+\r
+namespace ByteFX.Data.Common\r
+{\r
+       /// <summary>\r
+       /// Summary description for Utility.\r
+       /// </summary>\r
+       internal abstract class DBConnectionString\r
+       {\r
+               protected Hashtable     keyValues = new Hashtable();\r
+               protected string        connectionName = String.Empty;\r
+               protected string        connectString;\r
+\r
+               public DBConnectionString()\r
+               {       \r
+                       keyValues = GetDefaultValues();\r
+               }\r
+\r
+               public void SetConnectionString(string value)\r
+               {\r
+                       Hashtable ht = Parse( value );                  \r
+                       connectString = value;\r
+                       keyValues = ht;\r
+               }\r
+\r
+               protected string GetString(string name) \r
+               {\r
+                       if (! keyValues.ContainsKey(name)) return String.Empty;\r
+                       return (keyValues[name] as string);\r
+               }\r
+\r
+               protected int GetInt( string name ) \r
+               {\r
+                       return Convert.ToInt32(keyValues[name]);\r
+               }\r
+\r
+               protected bool GetBool( string name ) \r
+               {\r
+                       return Convert.ToBoolean(keyValues[name]);\r
+               }\r
+\r
+               protected virtual bool ConnectionParameterParsed(Hashtable hash, string key, string value)\r
+               {\r
+                       switch (key.ToLower()) \r
+                       {\r
+                               case "persist security info":\r
+                                       hash["persist security info"] = \r
+                                               value.ToLower() == "yes" || value.ToLower() == "true";\r
+                                       return true;\r
+\r
+                               case "uid":\r
+                               case "username":\r
+                               case "user id":\r
+                               case "user name": \r
+                               case "userid":\r
+                                       hash["user id"] = value;\r
+                                       return true;\r
+\r
+                               case "password": \r
+                               case "pwd":\r
+                                       hash["password"] = value;\r
+                                       return true;\r
+\r
+                               case "host":\r
+                               case "server":\r
+                               case "data source":\r
+                               case "datasource":\r
+                               case "address":\r
+                               case "addr":\r
+                               case "network address":\r
+                                       hash["host"] = value;\r
+                                       return true;\r
+                               \r
+                               case "initial catalog":\r
+                               case "database":\r
+                                       hash["database"] = value;\r
+                                       return true;\r
+\r
+                               case "connection timeout":\r
+                               case "connect timeout":\r
+                                       hash["connect timeout"] = Int32.Parse( value );\r
+                                       return true;\r
+\r
+                               case "port":\r
+                                       hash["port"] = Int32.Parse( value );\r
+                                       return true;\r
+\r
+                               case "pooling":\r
+                                       hash["pooling"] = \r
+                                               value.ToLower() == "yes" || value.ToLower() == "true";\r
+                                       return true;\r
+\r
+                               case "min pool size":\r
+                                       hash["min pool size"] = Int32.Parse(value);\r
+                                       return true;\r
+\r
+                               case "max pool size":\r
+                                       hash["max pool size"] = Int32.Parse(value);\r
+                                       return true;\r
+\r
+                               case "connection lifetime":\r
+                                       hash["connect lifetime"] = Int32.Parse(value);\r
+                                       return true;\r
+                       }\r
+                       return false;\r
+               }\r
+\r
+               protected virtual Hashtable GetDefaultValues()\r
+               {\r
+                       return null;\r
+               }\r
+\r
+               protected Hashtable ParseKeyValuePairs( string src )\r
+               {\r
+                       String[] keyvalues = src.Split( ';' );\r
+                       String[] newkeyvalues = new String[keyvalues.Length];\r
+                       int              x = 0;\r
+\r
+                       // first run through the array and check for any keys that\r
+                       // have ; in their value\r
+                       foreach (String keyvalue in keyvalues) \r
+                       {\r
+                               // check for trailing ; at the end of the connection string\r
+                               if (keyvalue.Length == 0) continue;\r
+\r
+                               // this value has an '=' sign so we are ok\r
+                               if (keyvalue.IndexOf('=') >= 0) \r
+                               {\r
+                                       newkeyvalues[x++] = keyvalue;\r
+                               }\r
+                               else \r
+                               {\r
+                                       newkeyvalues[x-1] += ";";\r
+                                       newkeyvalues[x-1] += keyvalue;\r
+                               }\r
+                       }\r
+\r
+                       Hashtable hash = new Hashtable();\r
+\r
+                       // now we run through our normalized key-values, splitting on equals\r
+                       for (int y=0; y < x; y++) \r
+                       {\r
+                               String[] parts = newkeyvalues[y].Split( '=' );\r
+\r
+                               // first trim off any space and lowercase the key\r
+                               parts[0] = parts[0].Trim().ToLower();\r
+                               parts[1] = parts[1].Trim();\r
+\r
+                               // we also want to clear off any quotes\r
+                               parts[0] = parts[0].Trim('\'', '"');\r
+                               parts[1] = parts[1].Trim('\'', '"');\r
+\r
+                               hash.Add( parts[0], parts[1] );\r
+                       }\r
+                       return hash;\r
+               }\r
+\r
+               protected virtual Hashtable Parse(string newConnectString) \r
+               {\r
+                       Hashtable hash = ParseKeyValuePairs( newConnectString );\r
+                       Hashtable newHash = GetDefaultValues();\r
+\r
+                       foreach (object key in hash.Keys)\r
+                               ConnectionParameterParsed( newHash, (string)key, (string)hash[key] );\r
+                       return newHash;\r
+               }\r
+\r
+\r
+       }\r
+}\r
index 0a555796100032eca14ebb2d6602e3c7608655a3..75d880216fa1f7b4b3d7fa31b817c2d246523c8b 100644 (file)
@@ -1,59 +1,59 @@
-// ByteFX.Data data access components for .Net
-// Copyright (C) 2002-2003  ByteFX, Inc.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// 
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-// 
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-using System;
-using System.ComponentModel.Design;
-using ByteFX.Data.MySqlClient;
-
-namespace ByteFX.Data.Common
-{
-       /// <summary>
-       /// Summary description for DBParametersEditor.
-       /// </summary>
-       internal class DBParametersEditor : CollectionEditor
-       {
-               public DBParametersEditor(Type t) : base(t)
-               {
-               }
-
-               protected override object CreateInstance(Type itemType)
-               {
-                       object[] items = base.GetItems(null);
-
-                       int i = 1;
-                       while (true) 
-                       {
-                               bool found = false;
-                               foreach (object obj in items) 
-                               {
-                                       MySqlParameter p = (MySqlParameter)obj;
-                                       if (p.ParameterName.Equals( "parameter" + i )) 
-                                       {
-                                               found = true;
-                                               break;
-                                       }
-                               }
-                               if (! found) break;
-                               i ++;
-                       }
-
-                       MySqlParameter parm = new MySqlParameter("parameter"+i, MySqlDbType.VarChar);
-                       return parm;
-               }
-
-       }
-}
+// ByteFX.Data data access components for .Net\r
+// Copyright (C) 2002-2003  ByteFX, Inc.\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License, or (at your option) any later version.\r
+// \r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+// Lesser General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+\r
+using System;\r
+using System.ComponentModel.Design;\r
+using ByteFX.Data.MySqlClient;\r
+\r
+namespace ByteFX.Data.Common\r
+{\r
+       /// <summary>\r
+       /// Summary description for DBParametersEditor.\r
+       /// </summary>\r
+       internal class DBParametersEditor : CollectionEditor\r
+       {\r
+               public DBParametersEditor(Type t) : base(t)\r
+               {\r
+               }\r
+\r
+               protected override object CreateInstance(Type itemType)\r
+               {\r
+                       object[] items = base.GetItems(null);\r
+\r
+                       int i = 1;\r
+                       while (true) \r
+                       {\r
+                               bool found = false;\r
+                               foreach (object obj in items) \r
+                               {\r
+                                       MySqlParameter p = (MySqlParameter)obj;\r
+                                       if (p.ParameterName.Equals( "parameter" + i )) \r
+                                       {\r
+                                               found = true;\r
+                                               break;\r
+                                       }\r
+                               }\r
+                               if (! found) break;\r
+                               i ++;\r
+                       }\r
+\r
+                       MySqlParameter parm = new MySqlParameter("parameter"+i, MySqlDbType.VarChar);\r
+                       return parm;\r
+               }\r
+\r
+       }\r
+}\r
index 132bf08939d1872e838bd76f6b28bc5cf2672fe5..6f1b84a0207fc4c161f40660397c16d72e578d72 100755 (executable)
@@ -1,51 +1,61 @@
-using System;
-using System.Data;
-using System.Data.SqlTypes;
-
-namespace ByteFX.Data.Common
-{
-       /// <summary>
-       /// Summary description for Field.
-       /// </summary>
-       internal class Field
-       {
-/*             protected       SqlByte         byteValue;
-               protected       SqlDateTime     dateValue;
-               protected       SqlString       stringValue;
-               protected       SqlInt32        int32Value;
-               protected       SqlInt64        int64Value;
-               protected       SqlDouble       doubleValue;
-               protected       SqlSingle       singleValue;
-               protected       SqlMoney        moneyValue;
-               protected       SqlDecimal      decimalValue;
-               protected       SqlBinary       binaryValue;*/
-               protected       object          value;
-
-               protected       string          tableName;
-               protected       string          colName;
-               protected       int                     colLen;
-               protected       DbType          dbType;
-               protected       bool            hasValue;
-
-               public Field()
-               {
-                       hasValue = false;
-               }
-
-               public string ColumnName 
-               {
-                       get { return colName; }
-               }
-
-               public int ColumnLength
-               {
-                       get { return colLen; }
-               }
-
-               public string TableName 
-               {
-                       get { return tableName; }
-               }
-
-       }
-}
+using System;\r
+using System.Data;\r
+using System.Data.SqlTypes;\r
+\r
+namespace ByteFX.Data.Common\r
+{\r
+       /// <summary>\r
+       /// Summary description for Field.\r
+       /// </summary>\r
+       internal class Field\r
+       {\r
+/*             protected       SqlByte         byteValue;\r
+               protected       SqlDateTime     dateValue;\r
+               protected       SqlString       stringValue;\r
+               protected       SqlInt32        int32Value;\r
+               protected       SqlInt64        int64Value;\r
+               protected       SqlDouble       doubleValue;\r
+               protected       SqlSingle       singleValue;\r
+               protected       SqlMoney        moneyValue;\r
+               protected       SqlDecimal      decimalValue;\r
+               protected       SqlBinary       binaryValue;*/\r
+               protected       object          value;\r
+\r
+               protected       string          tableName;\r
+               protected       string          colName;\r
+               protected       int                     colLen;\r
+               protected   string              catalogName;\r
+               protected       DbType          dbType;\r
+               protected       bool            hasValue;\r
+\r
+               public Field()\r
+               {\r
+                       hasValue = false;\r
+               }\r
+\r
+               public string ColumnName \r
+               {\r
+                       get { return colName; }\r
+                       set { colName = value; }\r
+               }\r
+\r
+               public int ColumnLength\r
+               {\r
+                       get { return colLen; }\r
+                       set { colLen = value; }\r
+               }\r
+\r
+               public string TableName \r
+               {\r
+                       get { return tableName; }\r
+                       set { tableName = value; }\r
+               }\r
+\r
+               public string CatalogName \r
+               {\r
+                       get { return catalogName; }\r
+                       set { catalogName = value; }\r
+               }\r
+\r
+       }\r
+}\r
index 827a8724d390ca0d736ffd9f7719663c9618d30c..593996b88d5efbfb64cd453fec21fd91bdf90a4f 100755 (executable)
@@ -1,76 +1,76 @@
-using System;
-
-namespace ByteFX.Data.Common
-{
-       /// <summary>
-       /// Summary description for HuffmanTree.
-       /// </summary>
-       public class HuffmanTree
-       {
-               const int MAX_BITS = 15;
-               int[]   codes;
-
-               public HuffmanTree(bool lit)
-               {
-                       if (lit)
-                               BuildLitTree();
-                       else
-                               BuildLenTree();
-               }
-
-               private void BuildLitTree()
-               {
-                       codes = new int[288];
-
-                       // fill the code slots with code lengths first
-                       for (int x=0; x < 144; x++)
-                               codes[x] = 8;
-                       for (int x=144; x < 256; x++)
-                               codes[x] = 9;
-                       for (int x=256; x < 280; x++)
-                               codes[x] = 7;
-                       for (int x=280; x < 288; x++)
-                               codes[x] = 8;
-
-                       BuildTreeCommon();
-               }
-
-
-               private void BuildLenTree()
-               {
-                       BuildTreeCommon();
-               }
-
-               private void BuildTreeCommon()
-               {
-                       int[] codecounts = new int[MAX_BITS];
-                       int[] codebase = new int[MAX_BITS];
-
-                       for (int i = 0; i < codes.Length; i++) 
-                       {
-                               int bit_len = codes[i];
-                               if (bit_len > 0)
-                                       codecounts[bit_len]++;
-                       }
-
-                       // now we compute the intial value for each code length
-                       int code = 0;
-                       codecounts[0] = 0;
-                       for (int bits = 1; bits <= MAX_BITS; bits++) 
-                       {
-                               code = (code + codecounts[bits-1]) << 1;
-                               codebase[bits] = code;
-                       }
-
-                       // next we assign numerical values to each code
-                       for (int x=0;  x <= codes.Length; x++) 
-                       {
-                               if (codes[x] == 0) continue;
-                               int blen = codes[x];
-                               codes[x] = codebase[ blen ];
-                               codebase[ blen ] ++;
-                       }
-               }
-
-       }
-}
+using System;\r
+\r
+namespace ByteFX.Data.Common\r
+{\r
+       /// <summary>\r
+       /// Summary description for HuffmanTree.\r
+       /// </summary>\r
+       public class HuffmanTree\r
+       {\r
+               const int MAX_BITS = 15;\r
+               int[]   codes;\r
+\r
+               public HuffmanTree(bool lit)\r
+               {\r
+                       if (lit)\r
+                               BuildLitTree();\r
+                       else\r
+                               BuildLenTree();\r
+               }\r
+\r
+               private void BuildLitTree()\r
+               {\r
+                       codes = new int[288];\r
+\r
+                       // fill the code slots with code lengths first\r
+                       for (int x=0; x < 144; x++)\r
+                               codes[x] = 8;\r
+                       for (int x=144; x < 256; x++)\r
+                               codes[x] = 9;\r
+                       for (int x=256; x < 280; x++)\r
+                               codes[x] = 7;\r
+                       for (int x=280; x < 288; x++)\r
+                               codes[x] = 8;\r
+\r
+                       BuildTreeCommon();\r
+               }\r
+\r
+\r
+               private void BuildLenTree()\r
+               {\r
+                       BuildTreeCommon();\r
+               }\r
+\r
+               private void BuildTreeCommon()\r
+               {\r
+                       int[] codecounts = new int[MAX_BITS];\r
+                       int[] codebase = new int[MAX_BITS];\r
+\r
+                       for (int i = 0; i < codes.Length; i++) \r
+                       {\r
+                               int bit_len = codes[i];\r
+                               if (bit_len > 0)\r
+                                       codecounts[bit_len]++;\r
+                       }\r
+\r
+                       // now we compute the intial value for each code length\r
+                       int code = 0;\r
+                       codecounts[0] = 0;\r
+                       for (int bits = 1; bits <= MAX_BITS; bits++) \r
+                       {\r
+                               code = (code + codecounts[bits-1]) << 1;\r
+                               codebase[bits] = code;\r
+                       }\r
+\r
+                       // next we assign numerical values to each code\r
+                       for (int x=0;  x <= codes.Length; x++) \r
+                       {\r
+                               if (codes[x] == 0) continue;\r
+                               int blen = codes[x];\r
+                               codes[x] = codebase[ blen ];\r
+                               codebase[ blen ] ++;\r
+                       }\r
+               }\r
+\r
+       }\r
+}\r
index 772e01b8e63a09b01d2962e91066bc8c5ec5dbab..fd9d0b1d8fc7e20b31848726215372b965f9a4e4 100755 (executable)
@@ -1,37 +1,37 @@
-using System;
-using System.IO;
-
-namespace ByteFX.Data.Common
-{
-       /// <summary>
-       /// Summary description for Inflater.
-       /// </summary>
-       public class Inflater
-       {
-               private BitStream _input;
-
-               public Inflater()
-               {
-               }
-
-               public void SetInput(byte[] input, int offset, int len)
-               {
-                       _input = new BitStream(input, offset, len);
-               }
-
-               public void Inflate(byte[] output, int offset, int size)
-               {
-                       byte cmf = (byte)_input.GetBits(8);
-                       byte flag = (byte)_input.GetBits(8);
-
-                       if ((cmf & 0x0f) != 8)
-                               throw new Exception("Only deflate format data is supported");
-
-                       if (((cmf*256+flag) % 31) != 0)
-                               throw new Exception("Data is not in proper deflate format");
-
-
-
-               }
-       }
-}
+using System;\r
+using System.IO;\r
+\r
+namespace ByteFX.Data.Common\r
+{\r
+       /// <summary>\r
+       /// Summary description for Inflater.\r
+       /// </summary>\r
+       public class Inflater\r
+       {\r
+               private BitStream _input;\r
+\r
+               public Inflater()\r
+               {\r
+               }\r
+\r
+               public void SetInput(byte[] input, int offset, int len)\r
+               {\r
+                       _input = new BitStream(input, offset, len);\r
+               }\r
+\r
+               public void Inflate(byte[] output, int offset, int size)\r
+               {\r
+                       byte cmf = (byte)_input.GetBits(8);\r
+                       byte flag = (byte)_input.GetBits(8);\r
+\r
+                       if ((cmf & 0x0f) != 8)\r
+                               throw new Exception("Only deflate format data is supported");\r
+\r
+                       if (((cmf*256+flag) % 31) != 0)\r
+                               throw new Exception("Data is not in proper deflate format");\r
+\r
+\r
+\r
+               }\r
+       }\r
+}\r
index 56a2c8f9534b113af137b90f30f3caf32b44f60e..1c3d6d5c8c8d2257f959928da46c57289f026c31 100644 (file)
-using System;
-using System.Net;
-using System.IO;
-using System.Collections;
-using System.Threading;
-
-namespace ByteFX.Data.Common
-{
-       internal enum MultiHostStreamErrorType 
-       {
-               Connecting,
-               Reading,
-               Writing
-       }
-
-       /// <summary>
-       /// Summary description for MultiHostStream.
-       /// </summary>
-       internal abstract class MultiHostStream : Stream
-       {
-               protected Stream        stream;
-               protected int           readTimeOut;
-               protected Exception     baseException;
-
-               /// <summary>
-               /// Constructs a new MultiHostStream object with the given parameters
-               /// </summary>
-               /// <param name="hostList"></param>
-               /// <param name="port"></param>
-               /// <param name="readTimeOut"></param>
-               /// <param name="connectTimeOut"></param>
-               public MultiHostStream(string hostList, int port, int readTimeOut, int connectTimeOut)
-               {
-                       this.readTimeOut = readTimeOut;
-                       ProcessHosts( hostList, port, connectTimeOut );
-               }
-
-               protected abstract void TimeOut(MultiHostStreamErrorType error);
-               protected abstract void Error(string msg);
-               protected abstract bool CreateStream( IPAddress ip, string host, int port );
-               protected abstract bool DataAvailable 
-               {
-                       get;
-               }
-
-               private void ProcessHosts( string hostList, int port, int connectTimeOut )
-               {
-                       int startTime = Environment.TickCount;
-
-                       int toTicks = connectTimeOut * 1000;
-                       //
-                       // Host name can contain multiple hosts, seperated by &.
-                       string [] dnsHosts = hostList.Split('&');
-                       Hashtable ips = new Hashtable();
-
-                       //
-                       // Each host name specified may contain multiple IP addresses
-                       // Lets look at the DNS entries for each host name
-                       foreach(string h in dnsHosts)
-                       {
-                               IPHostEntry hostAddress = Dns.GetHostByName(h);
-                               foreach (IPAddress addr in hostAddress.AddressList)
-                                       ips.Add( addr, hostAddress.HostName );
-                       }
-                       IPAddress[] keys = new IPAddress[ ips.Count ];
-                       ips.Keys.CopyTo( keys, 0 );
-
-                       if ((Environment.TickCount - startTime) > toTicks)
-                       {
-                               TimeOut(MultiHostStreamErrorType.Connecting);
-                               return;
-                       }
-
-                       // make sure they gave us at least one host
-                       if (ips.Count == 0)
-                       {
-                               Error("You must specify at least one host");
-                               return;
-                       }
-
-                       int index = 0;
-                       // now choose a random server if there are more than one
-                       if (ips.Count > 1) 
-                       {
-                               System.Random random = new Random((int)DateTime.Now.Ticks);
-                               index = random.Next(ips.Count-1);
-                       }
-
-                       //
-                       // Lets step through our hosts until we get a connection
-                       for (int i=0; i < ips.Count; i++)
-                       {
-                               if ((Environment.TickCount - startTime) > toTicks) 
-                               {
-                                       TimeOut(MultiHostStreamErrorType.Connecting);
-                                       return;
-                               }
-                               if (CreateStream( (IPAddress)keys[i], (string)ips[keys[i]], port ))
-                                       return;
-                       }
-               }
-
-               public override int ReadByte()
-               {
-                       int start = Environment.TickCount;
-                       int ticks = readTimeOut * 1000;
-
-                       while ((Environment.TickCount - start) < ticks)
-                       {
-                               if (DataAvailable)
-                               {
-                                       int b = stream.ReadByte();
-                                       return b;
-                               }
-                               else
-                                       Thread.Sleep(1);
-                       }
-
-                       TimeOut(MultiHostStreamErrorType.Reading);
-                       return -1;
-               }
-
-               public override int Read(byte[] buffer, int offset, int count)
-               {
-                       int  numToRead = count;
-                       int start = Environment.TickCount;
-                       int ticks = readTimeOut * 1000;
-
-                       while (numToRead > 0 && (Environment.TickCount - start) < ticks)
-                       {
-                               if (DataAvailable) 
-                               {
-                                       int bytes_read = stream.Read( buffer, offset, numToRead);
-                                       if (bytes_read == 0)
-                                               return (count - numToRead);
-                                       offset += bytes_read;
-                                       numToRead -= bytes_read;
-                               }
-                               Thread.Sleep(1);
-                       }
-
-                       if (numToRead > 0)
-                               TimeOut(MultiHostStreamErrorType.Reading);
-                       return count;
-               }
-
-               public override bool CanRead
-               {
-                       get { return stream.CanRead; }
-               }
-
-               public override bool CanWrite
-               {
-                       get { return stream.CanWrite; }
-               }
-
-               public override bool CanSeek
-               {
-                       get { return stream.CanSeek; }
-               }
-
-               public override long Length
-               {
-                       get { return stream.Length; }
-               }
-
-               public override long Position 
-               {
-                       get { return stream.Position; }
-                       set { stream.Position = value; }
-               }
-
-               public override void Flush() 
-               {
-                       stream.Flush();
-               }
-
-               public override void SetLength(long length)
-               {
-                       stream.SetLength( length );
-               }
-
-               public override void Write(byte[] buffer, int offset, int count)
-               {
-                       stream.Write( buffer, offset, count );
-               }
-
-               public override long Seek( long offset, SeekOrigin origin )
-               {
-                       return stream.Seek( offset, origin );
-               }
-
-       }
-}
+using System;\r
+using System.Net;\r
+using System.IO;\r
+using System.Collections;\r
+using System.Threading;\r
+\r
+namespace ByteFX.Data.Common\r
+{\r
+       internal enum MultiHostStreamErrorType \r
+       {\r
+               Connecting,\r
+               Reading,\r
+               Writing\r
+       }\r
+\r
+       /// <summary>\r
+       /// Summary description for MultiHostStream.\r
+       /// </summary>\r
+       internal abstract class MultiHostStream : Stream\r
+       {\r
+               protected Stream        stream;\r
+               protected int           readTimeOut;\r
+               protected Exception     baseException;\r
+\r
+               /// <summary>\r
+               /// Constructs a new MultiHostStream object with the given parameters\r
+               /// </summary>\r
+               /// <param name="hostList"></param>\r
+               /// <param name="port"></param>\r
+               /// <param name="readTimeOut"></param>\r
+               /// <param name="connectTimeOut"></param>\r
+               public MultiHostStream(string hostList, int port, int readTimeOut, int connectTimeOut)\r
+               {\r
+                       this.readTimeOut = readTimeOut;\r
+                       ProcessHosts( hostList, port, connectTimeOut );\r
+               }\r
+\r
+               // abstract members\r
+               protected abstract void TimeOut(MultiHostStreamErrorType error);\r
+               protected abstract void Error(string msg);\r
+               protected abstract bool CreateStream( IPAddress ip, string host, int port );\r
+               protected abstract bool CreateStream (string fileName);\r
+               protected abstract bool DataAvailable \r
+               {\r
+                       get;\r
+               }\r
+\r
+               private void ProcessHosts( string hostList, int port, int connectTimeOut )\r
+               {\r
+                       int startTime = Environment.TickCount;\r
+\r
+                       int toTicks = connectTimeOut * 1000;\r
+\r
+                       // support Unix sockets\r
+                       if (hostList.StartsWith ("/")) \r
+                       {\r
+                               CreateStream (hostList);\r
+                               return;\r
+                       } \r
+\r
+                       //\r
+                       // Host name can contain multiple hosts, seperated by &.\r
+                       string [] dnsHosts = hostList.Split('&');\r
+                       Hashtable ips = new Hashtable();\r
+\r
+                       //\r
+                       // Each host name specified may contain multiple IP addresses\r
+                       // Lets look at the DNS entries for each host name\r
+                       foreach(string h in dnsHosts)\r
+                       {\r
+                               IPHostEntry hostAddress = Dns.GetHostByName(h);\r
+                               foreach (IPAddress addr in hostAddress.AddressList)\r
+                                       ips.Add( addr, hostAddress.HostName );\r
+                       }\r
+                       IPAddress[] keys = new IPAddress[ ips.Count ];\r
+                       ips.Keys.CopyTo( keys, 0 );\r
+\r
+                       if ((Environment.TickCount - startTime) > toTicks)\r
+                       {\r
+                               TimeOut(MultiHostStreamErrorType.Connecting);\r
+                               return;\r
+                       }\r
+\r
+                       // make sure they gave us at least one host\r
+                       if (ips.Count == 0)\r
+                       {\r
+                               Error("You must specify at least one host");\r
+                               return;\r
+                       }\r
+\r
+                       int index = 0;\r
+                       // now choose a random server if there are more than one\r
+                       if (ips.Count > 1) \r
+                       {\r
+                               System.Random random = new Random((int)DateTime.Now.Ticks);\r
+                               index = random.Next(ips.Count-1);\r
+                       }\r
+\r
+                       //\r
+                       // Lets step through our hosts until we get a connection\r
+                       for (int i=0; i < ips.Count; i++)\r
+                       {\r
+                               if ((Environment.TickCount - startTime) > toTicks) \r
+                               {\r
+                                       TimeOut(MultiHostStreamErrorType.Connecting);\r
+                                       return;\r
+                               }\r
+                               if (CreateStream( (IPAddress)keys[i], (string)ips[keys[i]], port ))\r
+                                       return;\r
+                       }\r
+               }\r
+\r
+               public override int ReadByte()\r
+               {\r
+                       int start = Environment.TickCount;\r
+                       int ticks = readTimeOut * 1000;\r
+\r
+                       while ((Environment.TickCount - start) < ticks)\r
+                       {\r
+                               if (DataAvailable)\r
+                               {\r
+                                       int b = stream.ReadByte();\r
+                                       return b;\r
+                               }\r
+                               else\r
+                                       Thread.Sleep(0);\r
+                       }\r
+\r
+                       TimeOut(MultiHostStreamErrorType.Reading);\r
+                       return -1;\r
+               }\r
+\r
+               public override int Read(byte[] buffer, int offset, int count)\r
+               {\r
+                       int  numToRead = count;\r
+                       int start = Environment.TickCount;\r
+                       int ticks = readTimeOut * 1000;\r
+\r
+                       try \r
+                       {\r
+                               while (numToRead > 0 && (Environment.TickCount - start) < ticks)\r
+                               {\r
+                                       if (DataAvailable) \r
+                                       {\r
+                                               int bytes_read = stream.Read( buffer, offset, numToRead);\r
+                                               if (bytes_read == 0)\r
+                                                       return (count - numToRead);\r
+                                               offset += bytes_read;\r
+                                               numToRead -= bytes_read;\r
+                                       }\r
+                                       else\r
+                                               Thread.Sleep(0);\r
+                               }\r
+                       }\r
+                       catch (Exception ex)\r
+                       {\r
+                               Console.WriteLine(ex.Message);\r
+                       }\r
+\r
+                       if (numToRead > 0)\r
+                               TimeOut(MultiHostStreamErrorType.Reading);\r
+                       return count;\r
+               }\r
+\r
+               public override bool CanRead\r
+               {\r
+                       get { return stream.CanRead; }\r
+               }\r
+\r
+               public override bool CanWrite\r
+               {\r
+                       get { return stream.CanWrite; }\r
+               }\r
+\r
+               public override bool CanSeek\r
+               {\r
+                       get { return stream.CanSeek; }\r
+               }\r
+\r
+               public override long Length\r
+               {\r
+                       get { return stream.Length; }\r
+               }\r
+\r
+               public override long Position \r
+               {\r
+                       get { return stream.Position; }\r
+                       set { stream.Position = value; }\r
+               }\r
+\r
+               public override void Flush() \r
+               {\r
+                       stream.Flush();\r
+               }\r
+\r
+               public override void SetLength(long length)\r
+               {\r
+                       stream.SetLength( length );\r
+               }\r
+\r
+               public override void Write(byte[] buffer, int offset, int count)\r
+               {\r
+                       stream.Write( buffer, offset, count );\r
+               }\r
+\r
+               public override long Seek( long offset, SeekOrigin origin )\r
+               {\r
+                       return stream.Seek( offset, origin );\r
+               }\r
+\r
+       }\r
+}\r
index 5ebc5755cb82819860ee5699e1470059cc985a65..c2ef29a1a2ee8cbe1117544f40cd0fbaf4e9cc15 100755 (executable)
-// ByteFX.Data data access components for .Net
-// Copyright (C) 2002-2003  ByteFX, Inc.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// 
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-// 
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-using System;
-using System.IO;
-using System.Runtime.InteropServices;
-
-
-namespace ByteFX.Data.Common
-{
-       /// <summary>
-       /// Summary description for API.
-       /// </summary>
-       internal class NamedPipeStream : Stream
-       {
-               [DllImport("kernel32.dll", EntryPoint="CreateFile", SetLastError=true)]
-               private static extern IntPtr CreateFile(String lpFileName, 
-                       UInt32 dwDesiredAccess, UInt32 dwShareMode,
-                       IntPtr lpSecurityAttributes, UInt32 dwCreationDisposition, 
-                       UInt32 dwFlagsAndAttributes,
-                       IntPtr hTemplateFile);
-               [DllImport("kernel32.dll", EntryPoint="PeekNamedPipe", SetLastError=true)]
-               private static extern bool PeekNamedPipe( IntPtr handle,
-                       byte[] buffer, uint nBufferSize, ref uint bytesRead,
-                       ref uint bytesAvail, ref uint BytesLeftThisMessage);
-               [DllImport("kernel32.dll", SetLastError=true)]
-               private static extern bool ReadFile( IntPtr handle,
-                       byte[] buffer, uint toRead, ref uint read, IntPtr lpOverLapped);
-               [DllImport("kernel32.dll", SetLastError=true)]
-               private static extern bool WriteFile( IntPtr handle,
-                       byte[] buffer, uint count, ref uint written, IntPtr lpOverlapped );
-               [DllImport("kernel32.dll", SetLastError=true)]
-               private static extern bool CloseHandle( IntPtr handle );
-               [DllImport("kernel32.dll", SetLastError=true)]
-               private static extern bool FlushFileBuffers( IntPtr handle );
-
-               //Constants for dwDesiredAccess:
-               private const UInt32 GENERIC_READ = 0x80000000;
-               private const UInt32 GENERIC_WRITE = 0x40000000;
-
-               //Constants for return value:
-               private const Int32 INVALID_HANDLE_VALUE = -1;
-
-               //Constants for dwFlagsAndAttributes:
-               private const UInt32 FILE_FLAG_OVERLAPPED = 0x40000000;
-               private const UInt32 FILE_FLAG_NO_BUFFERING = 0x20000000;
-
-               //Constants for dwCreationDisposition:
-               private const UInt32 OPEN_EXISTING = 3;
-
-               IntPtr          _handle;
-               FileAccess      _mode;
-
-               public NamedPipeStream(string host, FileAccess mode)
-               {
-                       _handle = IntPtr.Zero;
-                       Open(host, mode);
-               }
-
-               public void Open( string host, FileAccess mode )
-               {
-                       _mode = mode;
-                       uint pipemode = 0;
-
-                       if ((mode & FileAccess.Read) > 0)
-                               pipemode |= GENERIC_READ;
-                       if ((mode & FileAccess.Write) > 0)
-                               pipemode |= GENERIC_WRITE;
-                       _handle = CreateFile( host, pipemode,
-                               0, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero );
-               }
-
-               public bool DataAvailable
-               {
-                       get 
-                       {
-                               uint bytesRead=0, avail=0, thismsg=0;
-
-                               bool result = PeekNamedPipe( _handle, 
-                                       null, 0, ref bytesRead, ref avail, ref thismsg );
-                               return (result == true && avail > 0);
-                       }
-       }
-
-               public override bool CanRead
-               {
-                       get { return (_mode & FileAccess.Read) > 0; }
-               }
-
-               public override bool CanWrite
-               {
-                       get { return (_mode & FileAccess.Write) > 0; }
-               }
-
-               public override bool CanSeek
-               {
-                       get { throw new NotSupportedException("NamedPipeStream does not support seeking"); }
-               }
-
-               public override long Length
-               {
-                       get { throw new NotSupportedException("NamedPipeStream does not support seeking"); }
-               }
-
-               public override long Position 
-               {
-                       get { throw new NotSupportedException("NamedPipeStream does not support seeking"); }
-                       set { }
-               }
-
-               public override void Flush() 
-               {
-                       if (_handle == IntPtr.Zero)
-                               throw new ObjectDisposedException("NamedPipeStream", "The stream has already been closed");
-                       FlushFileBuffers(_handle);
-               }
-
-               public override int Read(byte[] buffer, int offset, int count)
-               {
-                       if (buffer == null) 
-                               throw new ArgumentNullException("buffer", "The buffer to read into cannot be null");
-                       if (buffer.Length < (offset + count))
-                               throw new ArgumentException("Buffer is not large enough to hold requested data", "buffer");
-                       if (offset < 0) 
-                               throw new ArgumentOutOfRangeException("offset", offset, "Offset cannot be negative");
-                       if (count < 0)
-                               throw new ArgumentOutOfRangeException("count", count, "Count cannot be negative");
-                       if (! CanRead)
-                               throw new NotSupportedException("The stream does not support reading");
-                       if (_handle == IntPtr.Zero)
-                               throw new ObjectDisposedException("NamedPipeStream", "The stream has already been closed");
-
-                       // first read the data into an internal buffer since ReadFile cannot read into a buf at
-                       // a specified offset
-                       uint read=0;
-                       byte[] buf = new Byte[count];
-                       ReadFile( _handle, buf, (uint)count, ref read, IntPtr.Zero );
-                       
-                       for (int x=0; x < read; x++) 
-                       {
-                               buffer[offset+x] = buf[x];
-                       }
-                       return (int)read;
-               }
-
-               public override void Close()
-               {
-                       CloseHandle(_handle);
-                       _handle = IntPtr.Zero;
-               }
-
-               public override void SetLength(long length)
-               {
-                       throw new NotSupportedException("NamedPipeStream doesn't support SetLength");
-               }
-
-               public override void Write(byte[] buffer, int offset, int count)
-               {
-                       if (buffer == null) 
-                               throw new ArgumentNullException("buffer", "The buffer to write into cannot be null");
-                       if (buffer.Length < (offset + count))
-                               throw new ArgumentException("Buffer does not contain amount of requested data", "buffer");
-                       if (offset < 0) 
-                               throw new ArgumentOutOfRangeException("offset", offset, "Offset cannot be negative");
-                       if (count < 0)
-                               throw new ArgumentOutOfRangeException("count", count, "Count cannot be negative");
-                       if (! CanWrite)
-                               throw new NotSupportedException("The stream does not support writing");
-                       if (_handle == IntPtr.Zero)
-                               throw new ObjectDisposedException("NamedPipeStream", "The stream has already been closed");
-                       
-                       // copy data to internal buffer to allow writing from a specified offset
-                       byte[] buf = new Byte[count];
-                       for (int x=0; x < count; x++) 
-                       {
-                               buf[x] = buffer[offset+x];
-                       }
-                       uint written=0;
-                       bool result = WriteFile( _handle, buf, (uint)count, ref written, IntPtr.Zero );
-
-                       if (! result)
-                               throw new IOException("Writing to the stream failed");
-                       if (written < count)
-                               throw new IOException("Unable to write entire buffer to stream");
-               }
-
-               public override long Seek( long offset, SeekOrigin origin )
-               {
-                       throw new NotSupportedException("NamedPipeStream doesn't support seeking");
-               }
-       }
-}
-
-
+// ByteFX.Data data access components for .Net\r
+// Copyright (C) 2002-2003  ByteFX, Inc.\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License, or (at your option) any later version.\r
+// \r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+// Lesser General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+\r
+using System;\r
+using System.IO;\r
+using System.Runtime.InteropServices;\r
+\r
+\r
+namespace ByteFX.Data.Common\r
+{\r
+       /// <summary>\r
+       /// Summary description for API.\r
+       /// </summary>\r
+       internal class NamedPipeStream : Stream\r
+       {\r
+               [DllImport("kernel32.dll", EntryPoint="CreateFile", SetLastError=true)]\r
+               private static extern IntPtr CreateFile(String lpFileName, \r
+                       UInt32 dwDesiredAccess, UInt32 dwShareMode,\r
+                       IntPtr lpSecurityAttributes, UInt32 dwCreationDisposition, \r
+                       UInt32 dwFlagsAndAttributes,\r
+                       IntPtr hTemplateFile);\r
+               [DllImport("kernel32.dll", EntryPoint="PeekNamedPipe", SetLastError=true)]\r
+               private static extern bool PeekNamedPipe( IntPtr handle,\r
+                       byte[] buffer, uint nBufferSize, ref uint bytesRead,\r
+                       ref uint bytesAvail, ref uint BytesLeftThisMessage);\r
+               [DllImport("kernel32.dll", SetLastError=true)]\r
+               private static extern bool ReadFile( IntPtr handle,\r
+                       byte[] buffer, uint toRead, ref uint read, IntPtr lpOverLapped);\r
+               [DllImport("kernel32.dll", SetLastError=true)]\r
+               private static extern bool WriteFile( IntPtr handle,\r
+                       byte[] buffer, uint count, ref uint written, IntPtr lpOverlapped );\r
+               [DllImport("kernel32.dll", SetLastError=true)]\r
+               private static extern bool CloseHandle( IntPtr handle );\r
+               [DllImport("kernel32.dll", SetLastError=true)]\r
+               private static extern bool FlushFileBuffers( IntPtr handle );\r
+\r
+               //Constants for dwDesiredAccess:\r
+               private const UInt32 GENERIC_READ = 0x80000000;\r
+               private const UInt32 GENERIC_WRITE = 0x40000000;\r
+\r
+               //Constants for return value:\r
+               private const Int32 INVALID_HANDLE_VALUE = -1;\r
+\r
+               //Constants for dwFlagsAndAttributes:\r
+               private const UInt32 FILE_FLAG_OVERLAPPED = 0x40000000;\r
+               private const UInt32 FILE_FLAG_NO_BUFFERING = 0x20000000;\r
+\r
+               //Constants for dwCreationDisposition:\r
+               private const UInt32 OPEN_EXISTING = 3;\r
+\r
+               IntPtr          _handle;\r
+               FileAccess      _mode;\r
+\r
+               public NamedPipeStream(string host, FileAccess mode)\r
+               {\r
+                       _handle = IntPtr.Zero;\r
+                       Open(host, mode);\r
+               }\r
+\r
+               public void Open( string host, FileAccess mode )\r
+               {\r
+                       _mode = mode;\r
+                       uint pipemode = 0;\r
+\r
+                       if ((mode & FileAccess.Read) > 0)\r
+                               pipemode |= GENERIC_READ;\r
+                       if ((mode & FileAccess.Write) > 0)\r
+                               pipemode |= GENERIC_WRITE;\r
+                       _handle = CreateFile( host, pipemode,\r
+                               0, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero );\r
+               }\r
+\r
+               public bool DataAvailable\r
+               {\r
+                       get \r
+                       {\r
+                               uint bytesRead=0, avail=0, thismsg=0;\r
+\r
+                               bool result = PeekNamedPipe( _handle, \r
+                                       null, 0, ref bytesRead, ref avail, ref thismsg );\r
+                               return (result == true && avail > 0);\r
+                       }\r
+       }\r
+\r
+               public override bool CanRead\r
+               {\r
+                       get { return (_mode & FileAccess.Read) > 0; }\r
+               }\r
+\r
+               public override bool CanWrite\r
+               {\r
+                       get { return (_mode & FileAccess.Write) > 0; }\r
+               }\r
+\r
+               public override bool CanSeek\r
+               {\r
+                       get { throw new NotSupportedException("NamedPipeStream does not support seeking"); }\r
+               }\r
+\r
+               public override long Length\r
+               {\r
+                       get { throw new NotSupportedException("NamedPipeStream does not support seeking"); }\r
+               }\r
+\r
+               public override long Position \r
+               {\r
+                       get { throw new NotSupportedException("NamedPipeStream does not support seeking"); }\r
+                       set { }\r
+               }\r
+\r
+               public override void Flush() \r
+               {\r
+                       if (_handle == IntPtr.Zero)\r
+                               throw new ObjectDisposedException("NamedPipeStream", "The stream has already been closed");\r
+                       FlushFileBuffers(_handle);\r
+               }\r
+\r
+               public override int Read(byte[] buffer, int offset, int count)\r
+               {\r
+                       if (buffer == null) \r
+                               throw new ArgumentNullException("buffer", "The buffer to read into cannot be null");\r
+                       if (buffer.Length < (offset + count))\r
+                               throw new ArgumentException("Buffer is not large enough to hold requested data", "buffer");\r
+                       if (offset < 0) \r
+                               throw new ArgumentOutOfRangeException("offset", offset, "Offset cannot be negative");\r
+                       if (count < 0)\r
+                               throw new ArgumentOutOfRangeException("count", count, "Count cannot be negative");\r
+                       if (! CanRead)\r
+                               throw new NotSupportedException("The stream does not support reading");\r
+                       if (_handle == IntPtr.Zero)\r
+                               throw new ObjectDisposedException("NamedPipeStream", "The stream has already been closed");\r
+\r
+                       // first read the data into an internal buffer since ReadFile cannot read into a buf at\r
+                       // a specified offset\r
+                       uint read=0;\r
+                       byte[] buf = new Byte[count];\r
+                       ReadFile( _handle, buf, (uint)count, ref read, IntPtr.Zero );\r
+                       \r
+                       for (int x=0; x < read; x++) \r
+                       {\r
+                               buffer[offset+x] = buf[x];\r
+                       }\r
+                       return (int)read;\r
+               }\r
+\r
+               public override void Close()\r
+               {\r
+                       CloseHandle(_handle);\r
+                       _handle = IntPtr.Zero;\r
+               }\r
+\r
+               public override void SetLength(long length)\r
+               {\r
+                       throw new NotSupportedException("NamedPipeStream doesn't support SetLength");\r
+               }\r
+\r
+               public override void Write(byte[] buffer, int offset, int count)\r
+               {\r
+                       if (buffer == null) \r
+                               throw new ArgumentNullException("buffer", "The buffer to write into cannot be null");\r
+                       if (buffer.Length < (offset + count))\r
+                               throw new ArgumentException("Buffer does not contain amount of requested data", "buffer");\r
+                       if (offset < 0) \r
+                               throw new ArgumentOutOfRangeException("offset", offset, "Offset cannot be negative");\r
+                       if (count < 0)\r
+                               throw new ArgumentOutOfRangeException("count", count, "Count cannot be negative");\r
+                       if (! CanWrite)\r
+                               throw new NotSupportedException("The stream does not support writing");\r
+                       if (_handle == IntPtr.Zero)\r
+                               throw new ObjectDisposedException("NamedPipeStream", "The stream has already been closed");\r
+                       \r
+                       // copy data to internal buffer to allow writing from a specified offset\r
+                       byte[] buf = new Byte[count];\r
+                       for (int x=0; x < count; x++) \r
+                       {\r
+                               buf[x] = buffer[offset+x];\r
+                       }\r
+                       uint written=0;\r
+                       bool result = WriteFile( _handle, buf, (uint)count, ref written, IntPtr.Zero );\r
+\r
+                       if (! result)\r
+                               throw new IOException("Writing to the stream failed");\r
+                       if (written < count)\r
+                               throw new IOException("Unable to write entire buffer to stream");\r
+               }\r
+\r
+               public override long Seek( long offset, SeekOrigin origin )\r
+               {\r
+                       throw new NotSupportedException("NamedPipeStream doesn't support seeking");\r
+               }\r
+       }\r
+}\r
+\r
+\r
diff --git a/mcs/class/ByteFX.Data/Common/Platform.cs b/mcs/class/ByteFX.Data/Common/Platform.cs
new file mode 100644 (file)
index 0000000..31899ac
--- /dev/null
@@ -0,0 +1,41 @@
+using System;\r
+\r
+// ByteFX.Data data access components for .Net\r
+// Copyright (C) 2002-2004  ByteFX, Inc.\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License, or (at your option) any later version.\r
+// \r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+// Lesser General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+\r
+namespace ByteFX.Data.Common\r
+{\r
+       /// <summary>\r
+       /// Summary description for Platform.\r
+       /// </summary>\r
+       internal class Platform\r
+       {\r
+               public static bool IsWindows() \r
+               {\r
+                       OperatingSystem os = Environment.OSVersion;\r
+                       switch (os.Platform)\r
+                       {\r
+                               case PlatformID.Win32NT:\r
+                               case PlatformID.Win32S:\r
+                               case PlatformID.Win32Windows:\r
+                               case PlatformID.WinCE:\r
+                                       return true;\r
+                       }\r
+                               return false;\r
+               }\r
+       }\r
+}\r
index 0547e2e1a1b27aa0bdb5bff8cd8427151e681f3d..2279dcfe91dba2dc90c08b4453d58974136a6ab1 100644 (file)
@@ -1,25 +1,25 @@
-using System;
-
-namespace ByteFX.Data.Common
-{
-       /// <summary>
-       /// Summary description for Security.
-       /// </summary>
-       internal class Security
-       {
-               public Security()
-               {
-               }
-
-               public static void ArrayCrypt( byte[] src, int srcoff, byte[] dst, int dstoff, byte[] key, int length )
-               {
-                       int idx = 0;
-
-                       while ( (idx+srcoff) < src.Length && idx < length )
-                       {
-                               dst[idx+dstoff] = (byte)(src[idx+srcoff] ^ key[idx]);
-                               idx++;
-                       }
-               }
-       }
-}
+using System;\r
+\r
+namespace ByteFX.Data.Common\r
+{\r
+       /// <summary>\r
+       /// Summary description for Security.\r
+       /// </summary>\r
+       internal class Security\r
+       {\r
+               public Security()\r
+               {\r
+               }\r
+\r
+               public static void ArrayCrypt( byte[] src, int srcoff, byte[] dst, int dstoff, byte[] key, int length )\r
+               {\r
+                       int idx = 0;\r
+\r
+                       while ( (idx+srcoff) < src.Length && idx < length )\r
+                       {\r
+                               dst[idx+dstoff] = (byte)(src[idx+srcoff] ^ key[idx]);\r
+                               idx++;\r
+                       }\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/ByteFX.Data/Common/StreamCreator.cs b/mcs/class/ByteFX.Data/Common/StreamCreator.cs
new file mode 100644 (file)
index 0000000..654a9af
--- /dev/null
@@ -0,0 +1,148 @@
+// ByteFX.Data data access components for .Net\r
+// Copyright (C) 2002-2004  ByteFX, Inc.\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License, or (at your option) any later version.\r
+// \r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+// Lesser General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+\r
+using System;\r
+using System.IO;\r
+using System.Net;\r
+using System.Net.Sockets;\r
+using System.Collections;\r
+#if __MonoCS__ \r
+using Mono.Posix;\r
+#endif\r
+\r
+namespace ByteFX.Data.Common\r
+{\r
+       /// <summary>\r
+       /// Summary description for StreamCreator.\r
+       /// </summary>\r
+       internal class StreamCreator\r
+       {\r
+               string          hostList;\r
+               int                     port;\r
+               string          pipeName;\r
+               int                     timeOut;\r
+\r
+               public StreamCreator( string hosts, int port, string pipeName)\r
+               {\r
+                       hostList = hosts;\r
+                       this.port = port;\r
+                       this.pipeName = pipeName;\r
+               }\r
+\r
+               public Stream GetStream(int timeOut) \r
+               {\r
+                       this.timeOut = timeOut;\r
+\r
+                       if (hostList.StartsWith("/"))\r
+                               return CreateUnixSocketStream();\r
+\r
+                       string [] dnsHosts = hostList.Split('&');\r
+                       ArrayList ipAddresses = new ArrayList();\r
+                       ArrayList hostNames = new ArrayList();\r
+\r
+                       //\r
+                       // Each host name specified may contain multiple IP addresses\r
+                       // Lets look at the DNS entries for each host name\r
+                       foreach (string h in dnsHosts)\r
+                       {\r
+                               IPHostEntry hostAddress = Dns.GetHostByName(h);\r
+                               foreach (IPAddress addr in hostAddress.AddressList)\r
+                               {\r
+                                       ipAddresses.Add( addr );\r
+                                       hostNames.Add( hostAddress.HostName );\r
+                               }\r
+                       }\r
+\r
+                       System.Random random = new Random((int)DateTime.Now.Ticks);\r
+                       int index = random.Next(ipAddresses.Count-1);\r
+\r
+                       bool usePipe = pipeName != String.Empty;\r
+                       Stream stream = null;\r
+                       for (int i=0; i < ipAddresses.Count; i++)\r
+                       {\r
+                               if (usePipe)\r
+                                       stream = CreateNamedPipeStream( (string)hostNames[index] );\r
+                               else\r
+                                       stream = CreateSocketStream( (IPAddress)ipAddresses[index], port );\r
+                               if (stream != null) return stream;\r
+\r
+                               index++;\r
+                               if (index == ipAddresses.Count) index = 0;\r
+                       }\r
+\r
+                       return stream;\r
+               }\r
+\r
+               private Stream CreateUnixSocketStream() \r
+               {\r
+#if __MonoCS__ && !WINDOWS\r
+\r
+                       Socket socket = new Socket (AddressFamily.Unix, SocketType.Stream, ProtocolType.IP);\r
+\r
+                       try\r
+                       {\r
+                               UnixEndPoint endPoint = new UnixEndPoint (hostList[0]);\r
+                               socket.Connect (endPoint);\r
+                               return new NetworkStream (socket, true);\r
+                       }\r
+                       catch (Exception ex)\r
+                       {\r
+                               return null;\r
+                       }\r
+#else\r
+                       throw new PlatformNotSupportedException ("Unix sockets are only supported on this platform");\r
+#endif         \r
+               }\r
+\r
+               private Stream CreateNamedPipeStream( string hostname ) \r
+               {\r
+                       string pipePath;\r
+                       if (hostname.ToLower().Equals("localhost"))\r
+                               pipePath = @"\\.\pipe\" + pipeName;\r
+                       else\r
+                               pipePath = String.Format(@"\\{0}\pipe\{1}", hostname.ToString(), pipeName);\r
+                       return new NamedPipeStream(pipePath, FileAccess.ReadWrite);\r
+               }\r
+\r
+               private void ConnectSocketCallback( IAsyncResult iar )\r
+               {\r
+               }\r
+\r
+               private Stream CreateSocketStream( IPAddress ip, int port ) \r
+               {\r
+                       Socket socket = new Socket(AddressFamily.InterNetwork, \r
+                               SocketType.Stream, ProtocolType.Tcp);\r
+\r
+                       try\r
+                       {\r
+                               //\r
+                               // Lets try to connect\r
+                               IPEndPoint endPoint     = new IPEndPoint( ip, port);\r
+//                             IAsyncResult iar = socket.BeginConnect( endPoint, \r
+//                                     new AsyncCallback(ConnectSocketCallback), socket );\r
+\r
+                               socket.Connect(endPoint);\r
+                               socket.SetSocketOption( SocketOptionLevel.Tcp, SocketOptionName.NoDelay, 1 );\r
+                               return new NetworkStream( socket, true );\r
+                       }\r
+                       catch (Exception)\r
+                       {\r
+                               return null;\r
+                       }\r
+               }\r
+       }\r
+}\r
index 1d4d2b0506a7548a553b1b7a71f2b75ce5c1cb33..c8264f941f9ceb8e87a9c9605693cd800729da19 100644 (file)
@@ -1,67 +1,67 @@
-// ByteFX.Data data access components for .Net
-// Copyright (C) 2002-2003  ByteFX, Inc.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// 
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-// 
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-using System;
-using System.Text;
-using System.Collections;
-using System.Collections.Specialized;
-
-namespace ByteFX.Data.Common
-{
-       /// <summary>
-       /// Summary description for StringUtility.
-       /// </summary>
-       public class StringUtility
-       {
-               public StringUtility()
-               {
-               }
-
-               public static string[] Split( string src, char delimiter, params char[] quotedelims )
-               {
-                       ArrayList               strings = new ArrayList();
-                       StringBuilder   sb = new StringBuilder();
-                       ArrayList               ar = new ArrayList(quotedelims);
-                       char                    quote_open = Char.MinValue;
-
-                       foreach (char c in src) 
-                       {
-                               if (c == delimiter && quote_open == Char.MinValue) 
-                               {
-                                       strings.Add( sb.ToString() );
-                                       sb.Remove( 0, sb.Length );
-                               }
-                                       
-                               else if (ar.Contains(c)) 
-                               {
-                                       if (quote_open == Char.MinValue)
-                                               quote_open = c;
-                                       else if (quote_open == c)
-                                               quote_open = Char.MinValue;
-                                       sb.Append(c);
-                               }
-                               else
-                                       sb.Append( c );
-                       }
-
-                       if (sb.Length > 0)
-                               strings.Add( sb.ToString());
-
-                       return (string[])strings.ToArray(typeof(string));
-               }
-       }
-}
+// ByteFX.Data data access components for .Net\r
+// Copyright (C) 2002-2003  ByteFX, Inc.\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License, or (at your option) any later version.\r
+// \r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+// Lesser General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+\r
+using System;\r
+using System.Text;\r
+using System.Collections;\r
+using System.Collections.Specialized;\r
+\r
+namespace ByteFX.Data.Common\r
+{\r
+       /// <summary>\r
+       /// Summary description for StringUtility.\r
+       /// </summary>\r
+       public class StringUtility\r
+       {\r
+               public StringUtility()\r
+               {\r
+               }\r
+\r
+               public static string[] Split( string src, char delimiter, params char[] quotedelims )\r
+               {\r
+                       ArrayList               strings = new ArrayList();\r
+                       StringBuilder   sb = new StringBuilder();\r
+                       ArrayList               ar = new ArrayList(quotedelims);\r
+                       char                    quote_open = Char.MinValue;\r
+\r
+                       foreach (char c in src) \r
+                       {\r
+                               if (c == delimiter && quote_open == Char.MinValue) \r
+                               {\r
+                                       strings.Add( sb.ToString() );\r
+                                       sb.Remove( 0, sb.Length );\r
+                               }\r
+                                       \r
+                               else if (ar.Contains(c)) \r
+                               {\r
+                                       if (quote_open == Char.MinValue)\r
+                                               quote_open = c;\r
+                                       else if (quote_open == c)\r
+                                               quote_open = Char.MinValue;\r
+                                       sb.Append(c);\r
+                               }\r
+                               else\r
+                                       sb.Append( c );\r
+                       }\r
+\r
+                       if (sb.Length > 0)\r
+                               strings.Add( sb.ToString());\r
+\r
+                       return (string[])strings.ToArray(typeof(string));\r
+               }\r
+       }\r
+}\r
index 03b72a6a98578b4679a88350968c8a4bfad84226..bc68f74995468144cc187c367e88305a41ffb0b8 100644 (file)
@@ -1,51 +1,68 @@
-using System;
-
-namespace ByteFX.Data.Common
-{
-       /// <summary>
-       /// Summary description for Version.
-       /// </summary>
-       internal struct Version
-       {
-               private int     major;
-               private int minor;
-               private int build;
-
-               public Version( int major, int minor, int build)
-               {
-                       this.major = major;
-                       this.minor = minor;
-                       this.build = build;
-               }
-
-               public static Version Parse( string versionString )
-               {
-                       int start = 0;
-                       int index = versionString.IndexOf('.', start);
-                       if (index == -1) throw new Exception("Version string not in acceptable format");
-                       int major = Convert.ToInt32( versionString.Substring(start, index-start).Trim());
-
-                       start = index+1;
-                       index = versionString.IndexOf('.', start);
-                       if (index == -1) throw new Exception("Version string not in acceptable format");
-                       int minor = Convert.ToInt32( versionString.Substring(start, index-start).Trim());
-
-                       start = index+1;
-                       int i = start;
-                       while (i < versionString.Length && Char.IsDigit( versionString, i ))
-                               i++;
-                       int build = Convert.ToInt32( versionString.Substring(start, i-start).Trim());
-
-                       return new Version( major, minor, build );
-               }
-
-               public bool isAtLeast(int major, int minor, int build)
-               {
-                       if (major > this.major) return false;
-                       if (minor > this.minor) return false;
-                       if (build > this.build) return false;
-                       return true;
-               }
-
-       }
-}
+// ByteFX.Data data access components for .Net\r
+// Copyright (C) 2002-2004  ByteFX, Inc.\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License, or (at your option) any later version.\r
+// \r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+// Lesser General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+\r
+using System;\r
+\r
+namespace ByteFX.Data.Common\r
+{\r
+       /// <summary>\r
+       /// Summary description for Version.\r
+       /// </summary>\r
+       internal struct DBVersion\r
+       {\r
+               private int     major;\r
+               private int minor;\r
+               private int build;\r
+\r
+               public DBVersion( int major, int minor, int build)\r
+               {\r
+                       this.major = major;\r
+                       this.minor = minor;\r
+                       this.build = build;\r
+               }\r
+\r
+               public static DBVersion Parse( string versionString )\r
+               {\r
+                       int start = 0;\r
+                       int index = versionString.IndexOf('.', start);\r
+                       if (index == -1) throw new Exception("Version string not in acceptable format");\r
+                       int major = Convert.ToInt32( versionString.Substring(start, index-start).Trim());\r
+\r
+                       start = index+1;\r
+                       index = versionString.IndexOf('.', start);\r
+                       if (index == -1) throw new Exception("Version string not in acceptable format");\r
+                       int minor = Convert.ToInt32( versionString.Substring(start, index-start).Trim());\r
+\r
+                       start = index+1;\r
+                       int i = start;\r
+                       while (i < versionString.Length && Char.IsDigit( versionString, i ))\r
+                               i++;\r
+                       int build = Convert.ToInt32( versionString.Substring(start, i-start).Trim());\r
+\r
+                       return new DBVersion( major, minor, build );\r
+               }\r
+\r
+               public bool isAtLeast(int major, int minor, int build)\r
+               {\r
+                       if (this.major > major) return true;\r
+                       if (this.major == major && this.minor > minor) return true;\r
+                       if (this.major == major && this.minor == minor && this.build >= build) return true;\r
+                       return false;\r
+               }\r
+\r
+       }\r
+}\r
diff --git a/mcs/class/ByteFX.Data/MySqlClient.csproj b/mcs/class/ByteFX.Data/MySqlClient.csproj
new file mode 100644 (file)
index 0000000..ab53ae6
--- /dev/null
@@ -0,0 +1,339 @@
+<VisualStudioProject>\r
+    <CSHARP\r
+        ProjectType = "Local"\r
+        ProductVersion = "7.10.3077"\r
+        SchemaVersion = "2.0"\r
+        ProjectGuid = "{5EAEFBC4-8389-4120-BAB3-9B27174F6F6F}"\r
+    >\r
+        <Build>\r
+            <Settings\r
+                ApplicationIcon = ""\r
+                AssemblyKeyContainerName = ""\r
+                AssemblyName = "ByteFX.MySqlClient"\r
+                AssemblyOriginatorKeyFile = ""\r
+                DefaultClientScript = "JScript"\r
+                DefaultHTMLPageLayout = "Grid"\r
+                DefaultTargetSchema = "IE50"\r
+                DelaySign = "false"\r
+                OutputType = "Library"\r
+                PreBuildEvent = ""\r
+                PostBuildEvent = ""\r
+                RootNamespace = "ByteFX.Data.MySqlClient"\r
+                RunPostBuildEvent = "OnBuildSuccess"\r
+                StartupObject = ""\r
+            >\r
+                <Config\r
+                    Name = "Debug"\r
+                    AllowUnsafeBlocks = "false"\r
+                    BaseAddress = "285212672"\r
+                    CheckForOverflowUnderflow = "false"\r
+                    ConfigurationOverrideFile = ""\r
+                    DefineConstants = "DEBUG;TRACE;WINDOWS"\r
+                    DocumentationFile = "doc.xml"\r
+                    DebugSymbols = "true"\r
+                    FileAlignment = "4096"\r
+                    IncrementalBuild = "true"\r
+                    NoStdLib = "false"\r
+                    NoWarn = "1591"\r
+                    Optimize = "false"\r
+                    OutputPath = "bin\Debug\"\r
+                    RegisterForComInterop = "false"\r
+                    RemoveIntegerChecks = "false"\r
+                    TreatWarningsAsErrors = "false"\r
+                    WarningLevel = "4"\r
+                />\r
+                <Config\r
+                    Name = "Release"\r
+                    AllowUnsafeBlocks = "false"\r
+                    BaseAddress = "285212672"\r
+                    CheckForOverflowUnderflow = "false"\r
+                    ConfigurationOverrideFile = ""\r
+                    DefineConstants = "TRACE;WINDOWS"\r
+                    DocumentationFile = "doc.xml"\r
+                    DebugSymbols = "false"\r
+                    FileAlignment = "4096"\r
+                    IncrementalBuild = "false"\r
+                    NoStdLib = "false"\r
+                    NoWarn = "1591"\r
+                    Optimize = "true"\r
+                    OutputPath = "bin\Release\"\r
+                    RegisterForComInterop = "false"\r
+                    RemoveIntegerChecks = "false"\r
+                    TreatWarningsAsErrors = "false"\r
+                    WarningLevel = "4"\r
+                />\r
+            </Settings>\r
+            <References>\r
+                <Reference\r
+                    Name = "System"\r
+                    AssemblyName = "System"\r
+                    HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.dll"\r
+                />\r
+                <Reference\r
+                    Name = "System.Data"\r
+                    AssemblyName = "System.Data"\r
+                    HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.Data.dll"\r
+                />\r
+                <Reference\r
+                    Name = "System.XML"\r
+                    AssemblyName = "System.Xml"\r
+                    HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.XML.dll"\r
+                />\r
+                <Reference\r
+                    Name = "System.Design"\r
+                    AssemblyName = "System.Design"\r
+                    HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Design.dll"\r
+                />\r
+                <Reference\r
+                    Name = "System.Drawing"\r
+                    AssemblyName = "System.Drawing"\r
+                    HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Drawing.dll"\r
+                />\r
+                <Reference\r
+                    Name = "System.Windows.Forms"\r
+                    AssemblyName = "System.Windows.Forms"\r
+                    HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Windows.Forms.dll"\r
+                />\r
+                <Reference\r
+                    Name = "ICSharpCode.SharpZipLib"\r
+                    AssemblyName = "ICSharpCode.SharpZipLib"\r
+                    HintPath = "ICSharpCode.SharpZipLib.dll"\r
+                />\r
+            </References>\r
+        </Build>\r
+        <Files>\r
+            <Include>\r
+                <File\r
+                    RelPath = "AssemblyInfo.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "ChangeLog.txt"\r
+                    BuildAction = "Content"\r
+                />\r
+                <File\r
+                    RelPath = "internals.html"\r
+                    BuildAction = "Content"\r
+                />\r
+                <File\r
+                    RelPath = "Common\DBConnectionString.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "Common\DBParametersEditor.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "Common\Field.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "Common\NamedPipeStream.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "Common\Platform.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "Common\Security.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "Common\StreamCreator.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "Common\Version.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\CharSetMap.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\command.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\command.resx"\r
+                    DependentUpon = "command.cs"\r
+                    BuildAction = "EmbeddedResource"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\CommandBuilder.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\CommandResult.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\CompressedStream.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\Connection.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\Connection.resx"\r
+                    DependentUpon = "Connection.cs"\r
+                    BuildAction = "EmbeddedResource"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\ConnectionInternal.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\ConnectionString.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\dataadapter.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\datareader.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\Driver.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\Exception.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\Field.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\MysqlDefs.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\MySqlError.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\MySqlHelper.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\MySqlPool.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\MySqlPoolManager.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\Packet.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\parameter.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\parameter_collection.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\todo.txt"\r
+                    BuildAction = "Content"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\transaction.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\docs\MySqlCommand.xml"\r
+                    BuildAction = "Content"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\docs\MySqlCommandBuilder.xml"\r
+                    BuildAction = "Content"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\docs\MySqlConnection.xml"\r
+                    BuildAction = "Content"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\docs\MySqlDataAdapter.xml"\r
+                    BuildAction = "Content"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\docs\MySqlDataReader.xml"\r
+                    BuildAction = "Content"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\docs\MySqlException.xml"\r
+                    BuildAction = "Content"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\docs\MySqlHelper.xml"\r
+                    BuildAction = "Content"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\docs\MySqlParameter.xml"\r
+                    BuildAction = "Content"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\docs\MySqlParameterCollection.xml"\r
+                    BuildAction = "Content"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\docs\MySqlTransaction.xml"\r
+                    BuildAction = "Content"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\resources\command.bmp"\r
+                    BuildAction = "EmbeddedResource"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\resources\connection.bmp"\r
+                    BuildAction = "EmbeddedResource"\r
+                />\r
+                <File\r
+                    RelPath = "MySqlClient\resources\dataadapter.bmp"\r
+                    BuildAction = "EmbeddedResource"\r
+                />\r
+            </Include>\r
+        </Files>\r
+    </CSHARP>\r
+</VisualStudioProject>\r
+\r
index b1e3f5a2638797271cbc9b91b856c05ed6942c8f..cbee875ba6ddb0dadab286daf7ccec2f6f64191f 100755 (executable)
-                 GNU LESSER GENERAL PUBLIC LICENSE
-                      Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
-     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL.  It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
-                           Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
-  This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it.  You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
-  When we speak of free software, we are referring to freedom of use,
-not price.  Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
-  To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights.  These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
-  For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you.  You must make sure that they, too, receive or can get the source
-code.  If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it.  And you must show them these terms so they know their rights.
-
-  We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
-  To protect each distributor, we want to make it very clear that
-there is no warranty for the free library.  Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-\f
-  Finally, software patents pose a constant threat to the existence of
-any free program.  We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder.  Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
-  Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License.  This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License.  We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
-  When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library.  The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom.  The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
-  We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License.  It also provides other free software developers Less
-of an advantage over competing non-free programs.  These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries.  However, the Lesser license provides advantages in certain
-special circumstances.
-
-  For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard.  To achieve this, non-free programs must be
-allowed to use the library.  A more frequent case is that a free
-library does the same job as widely used non-free libraries.  In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
-  In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software.  For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
-  Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.  Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library".  The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-\f
-                 GNU LESSER GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
-  A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
-  The "Library", below, refers to any such software library or work
-which has been distributed under these terms.  A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language.  (Hereinafter, translation is
-included without limitation in the term "modification".)
-
-  "Source code" for a work means the preferred form of the work for
-making modifications to it.  For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
-  Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it).  Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-  
-  1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
-  You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-\f
-  2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) The modified work must itself be a software library.
-
-    b) You must cause the files modified to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    c) You must cause the whole of the work to be licensed at no
-    charge to all third parties under the terms of this License.
-
-    d) If a facility in the modified Library refers to a function or a
-    table of data to be supplied by an application program that uses
-    the facility, other than as an argument passed when the facility
-    is invoked, then you must make a good faith effort to ensure that,
-    in the event an application does not supply such function or
-    table, the facility still operates, and performs whatever part of
-    its purpose remains meaningful.
-
-    (For example, a function in a library to compute square roots has
-    a purpose that is entirely well-defined independent of the
-    application.  Therefore, Subsection 2d requires that any
-    application-supplied function or table used by this function must
-    be optional: if the application does not supply it, the square
-    root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library.  To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License.  (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.)  Do not make any other change in
-these notices.
-\f
-  Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
-  This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
-  4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
-  If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library".  Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
-  However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library".  The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
-  When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library.  The
-threshold for this to be true is not precisely defined by law.
-
-  If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work.  (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
-  Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-\f
-  6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
-  You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License.  You must supply a copy of this License.  If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License.  Also, you must do one
-of these things:
-
-    a) Accompany the work with the complete corresponding
-    machine-readable source code for the Library including whatever
-    changes were used in the work (which must be distributed under
-    Sections 1 and 2 above); and, if the work is an executable linked
-    with the Library, with the complete machine-readable "work that
-    uses the Library", as object code and/or source code, so that the
-    user can modify the Library and then relink to produce a modified
-    executable containing the modified Library.  (It is understood
-    that the user who changes the contents of definitions files in the
-    Library will not necessarily be able to recompile the application
-    to use the modified definitions.)
-
-    b) Use a suitable shared library mechanism for linking with the
-    Library.  A suitable mechanism is one that (1) uses at run time a
-    copy of the library already present on the user's computer system,
-    rather than copying library functions into the executable, and (2)
-    will operate properly with a modified version of the library, if
-    the user installs one, as long as the modified version is
-    interface-compatible with the version that the work was made with.
-
-    c) Accompany the work with a written offer, valid for at
-    least three years, to give the same user the materials
-    specified in Subsection 6a, above, for a charge no more
-    than the cost of performing this distribution.
-
-    d) If distribution of the work is made by offering access to copy
-    from a designated place, offer equivalent access to copy the above
-    specified materials from the same place.
-
-    e) Verify that the user has already received a copy of these
-    materials or that you have already sent this user a copy.
-
-  For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it.  However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
-  It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system.  Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-\f
-  7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
-    a) Accompany the combined library with a copy of the same work
-    based on the Library, uncombined with any other library
-    facilities.  This must be distributed under the terms of the
-    Sections above.
-
-    b) Give prominent notice with the combined library of the fact
-    that part of it is a work based on the Library, and explaining
-    where to find the accompanying uncombined form of the same work.
-
-  8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License.  Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License.  However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
-  9. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Library or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
-  10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-\f
-  11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded.  In such case, this License incorporates the limitation as if
-written in the body of this License.
-
-  13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation.  If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-\f
-  14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission.  For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this.  Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
-                           NO WARRANTY
-
-  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
-                    END OF TERMS AND CONDITIONS
-\f
-           How to Apply These Terms to Your New Libraries
-
-  If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change.  You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
-  To apply these terms, attach the following notices to the library.  It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the library's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the
-  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
-  <signature of Ty Coon>, 1 April 1990
-  Ty Coon, President of Vice
-
-That's all there is to it!
-
-
+                 GNU LESSER GENERAL PUBLIC LICENSE\r
+                      Version 2.1, February 1999\r
+\r
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.\r
+     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ Everyone is permitted to copy and distribute verbatim copies\r
+ of this license document, but changing it is not allowed.\r
+\r
+[This is the first released version of the Lesser GPL.  It also counts\r
+ as the successor of the GNU Library Public License, version 2, hence\r
+ the version number 2.1.]\r
+\r
+                           Preamble\r
+\r
+  The licenses for most software are designed to take away your\r
+freedom to share and change it.  By contrast, the GNU General Public\r
+Licenses are intended to guarantee your freedom to share and change\r
+free software--to make sure the software is free for all its users.\r
+\r
+  This license, the Lesser General Public License, applies to some\r
+specially designated software packages--typically libraries--of the\r
+Free Software Foundation and other authors who decide to use it.  You\r
+can use it too, but we suggest you first think carefully about whether\r
+this license or the ordinary General Public License is the better\r
+strategy to use in any particular case, based on the explanations below.\r
+\r
+  When we speak of free software, we are referring to freedom of use,\r
+not price.  Our General Public Licenses are designed to make sure that\r
+you have the freedom to distribute copies of free software (and charge\r
+for this service if you wish); that you receive source code or can get\r
+it if you want it; that you can change the software and use pieces of\r
+it in new free programs; and that you are informed that you can do\r
+these things.\r
+\r
+  To protect your rights, we need to make restrictions that forbid\r
+distributors to deny you these rights or to ask you to surrender these\r
+rights.  These restrictions translate to certain responsibilities for\r
+you if you distribute copies of the library or if you modify it.\r
+\r
+  For example, if you distribute copies of the library, whether gratis\r
+or for a fee, you must give the recipients all the rights that we gave\r
+you.  You must make sure that they, too, receive or can get the source\r
+code.  If you link other code with the library, you must provide\r
+complete object files to the recipients, so that they can relink them\r
+with the library after making changes to the library and recompiling\r
+it.  And you must show them these terms so they know their rights.\r
+\r
+  We protect your rights with a two-step method: (1) we copyright the\r
+library, and (2) we offer you this license, which gives you legal\r
+permission to copy, distribute and/or modify the library.\r
+\r
+  To protect each distributor, we want to make it very clear that\r
+there is no warranty for the free library.  Also, if the library is\r
+modified by someone else and passed on, the recipients should know\r
+that what they have is not the original version, so that the original\r
+author's reputation will not be affected by problems that might be\r
+introduced by others.\r
+\f\r
+  Finally, software patents pose a constant threat to the existence of\r
+any free program.  We wish to make sure that a company cannot\r
+effectively restrict the users of a free program by obtaining a\r
+restrictive license from a patent holder.  Therefore, we insist that\r
+any patent license obtained for a version of the library must be\r
+consistent with the full freedom of use specified in this license.\r
+\r
+  Most GNU software, including some libraries, is covered by the\r
+ordinary GNU General Public License.  This license, the GNU Lesser\r
+General Public License, applies to certain designated libraries, and\r
+is quite different from the ordinary General Public License.  We use\r
+this license for certain libraries in order to permit linking those\r
+libraries into non-free programs.\r
+\r
+  When a program is linked with a library, whether statically or using\r
+a shared library, the combination of the two is legally speaking a\r
+combined work, a derivative of the original library.  The ordinary\r
+General Public License therefore permits such linking only if the\r
+entire combination fits its criteria of freedom.  The Lesser General\r
+Public License permits more lax criteria for linking other code with\r
+the library.\r
+\r
+  We call this license the "Lesser" General Public License because it\r
+does Less to protect the user's freedom than the ordinary General\r
+Public License.  It also provides other free software developers Less\r
+of an advantage over competing non-free programs.  These disadvantages\r
+are the reason we use the ordinary General Public License for many\r
+libraries.  However, the Lesser license provides advantages in certain\r
+special circumstances.\r
+\r
+  For example, on rare occasions, there may be a special need to\r
+encourage the widest possible use of a certain library, so that it becomes\r
+a de-facto standard.  To achieve this, non-free programs must be\r
+allowed to use the library.  A more frequent case is that a free\r
+library does the same job as widely used non-free libraries.  In this\r
+case, there is little to gain by limiting the free library to free\r
+software only, so we use the Lesser General Public License.\r
+\r
+  In other cases, permission to use a particular library in non-free\r
+programs enables a greater number of people to use a large body of\r
+free software.  For example, permission to use the GNU C Library in\r
+non-free programs enables many more people to use the whole GNU\r
+operating system, as well as its variant, the GNU/Linux operating\r
+system.\r
+\r
+  Although the Lesser General Public License is Less protective of the\r
+users' freedom, it does ensure that the user of a program that is\r
+linked with the Library has the freedom and the wherewithal to run\r
+that program using a modified version of the Library.\r
+\r
+  The precise terms and conditions for copying, distribution and\r
+modification follow.  Pay close attention to the difference between a\r
+"work based on the library" and a "work that uses the library".  The\r
+former contains code derived from the library, whereas the latter must\r
+be combined with the library in order to run.\r
+\f\r
+                 GNU LESSER GENERAL PUBLIC LICENSE\r
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\r
+\r
+  0. This License Agreement applies to any software library or other\r
+program which contains a notice placed by the copyright holder or\r
+other authorized party saying it may be distributed under the terms of\r
+this Lesser General Public License (also called "this License").\r
+Each licensee is addressed as "you".\r
+\r
+  A "library" means a collection of software functions and/or data\r
+prepared so as to be conveniently linked with application programs\r
+(which use some of those functions and data) to form executables.\r
+\r
+  The "Library", below, refers to any such software library or work\r
+which has been distributed under these terms.  A "work based on the\r
+Library" means either the Library or any derivative work under\r
+copyright law: that is to say, a work containing the Library or a\r
+portion of it, either verbatim or with modifications and/or translated\r
+straightforwardly into another language.  (Hereinafter, translation is\r
+included without limitation in the term "modification".)\r
+\r
+  "Source code" for a work means the preferred form of the work for\r
+making modifications to it.  For a library, complete source code means\r
+all the source code for all modules it contains, plus any associated\r
+interface definition files, plus the scripts used to control compilation\r
+and installation of the library.\r
+\r
+  Activities other than copying, distribution and modification are not\r
+covered by this License; they are outside its scope.  The act of\r
+running a program using the Library is not restricted, and output from\r
+such a program is covered only if its contents constitute a work based\r
+on the Library (independent of the use of the Library in a tool for\r
+writing it).  Whether that is true depends on what the Library does\r
+and what the program that uses the Library does.\r
+  \r
+  1. You may copy and distribute verbatim copies of the Library's\r
+complete source code as you receive it, in any medium, provided that\r
+you conspicuously and appropriately publish on each copy an\r
+appropriate copyright notice and disclaimer of warranty; keep intact\r
+all the notices that refer to this License and to the absence of any\r
+warranty; and distribute a copy of this License along with the\r
+Library.\r
+\r
+  You may charge a fee for the physical act of transferring a copy,\r
+and you may at your option offer warranty protection in exchange for a\r
+fee.\r
+\f\r
+  2. You may modify your copy or copies of the Library or any portion\r
+of it, thus forming a work based on the Library, and copy and\r
+distribute such modifications or work under the terms of Section 1\r
+above, provided that you also meet all of these conditions:\r
+\r
+    a) The modified work must itself be a software library.\r
+\r
+    b) You must cause the files modified to carry prominent notices\r
+    stating that you changed the files and the date of any change.\r
+\r
+    c) You must cause the whole of the work to be licensed at no\r
+    charge to all third parties under the terms of this License.\r
+\r
+    d) If a facility in the modified Library refers to a function or a\r
+    table of data to be supplied by an application program that uses\r
+    the facility, other than as an argument passed when the facility\r
+    is invoked, then you must make a good faith effort to ensure that,\r
+    in the event an application does not supply such function or\r
+    table, the facility still operates, and performs whatever part of\r
+    its purpose remains meaningful.\r
+\r
+    (For example, a function in a library to compute square roots has\r
+    a purpose that is entirely well-defined independent of the\r
+    application.  Therefore, Subsection 2d requires that any\r
+    application-supplied function or table used by this function must\r
+    be optional: if the application does not supply it, the square\r
+    root function must still compute square roots.)\r
+\r
+These requirements apply to the modified work as a whole.  If\r
+identifiable sections of that work are not derived from the Library,\r
+and can be reasonably considered independent and separate works in\r
+themselves, then this License, and its terms, do not apply to those\r
+sections when you distribute them as separate works.  But when you\r
+distribute the same sections as part of a whole which is a work based\r
+on the Library, the distribution of the whole must be on the terms of\r
+this License, whose permissions for other licensees extend to the\r
+entire whole, and thus to each and every part regardless of who wrote\r
+it.\r
+\r
+Thus, it is not the intent of this section to claim rights or contest\r
+your rights to work written entirely by you; rather, the intent is to\r
+exercise the right to control the distribution of derivative or\r
+collective works based on the Library.\r
+\r
+In addition, mere aggregation of another work not based on the Library\r
+with the Library (or with a work based on the Library) on a volume of\r
+a storage or distribution medium does not bring the other work under\r
+the scope of this License.\r
+\r
+  3. You may opt to apply the terms of the ordinary GNU General Public\r
+License instead of this License to a given copy of the Library.  To do\r
+this, you must alter all the notices that refer to this License, so\r
+that they refer to the ordinary GNU General Public License, version 2,\r
+instead of to this License.  (If a newer version than version 2 of the\r
+ordinary GNU General Public License has appeared, then you can specify\r
+that version instead if you wish.)  Do not make any other change in\r
+these notices.\r
+\f\r
+  Once this change is made in a given copy, it is irreversible for\r
+that copy, so the ordinary GNU General Public License applies to all\r
+subsequent copies and derivative works made from that copy.\r
+\r
+  This option is useful when you wish to copy part of the code of\r
+the Library into a program that is not a library.\r
+\r
+  4. You may copy and distribute the Library (or a portion or\r
+derivative of it, under Section 2) in object code or executable form\r
+under the terms of Sections 1 and 2 above provided that you accompany\r
+it with the complete corresponding machine-readable source code, which\r
+must be distributed under the terms of Sections 1 and 2 above on a\r
+medium customarily used for software interchange.\r
+\r
+  If distribution of object code is made by offering access to copy\r
+from a designated place, then offering equivalent access to copy the\r
+source code from the same place satisfies the requirement to\r
+distribute the source code, even though third parties are not\r
+compelled to copy the source along with the object code.\r
+\r
+  5. A program that contains no derivative of any portion of the\r
+Library, but is designed to work with the Library by being compiled or\r
+linked with it, is called a "work that uses the Library".  Such a\r
+work, in isolation, is not a derivative work of the Library, and\r
+therefore falls outside the scope of this License.\r
+\r
+  However, linking a "work that uses the Library" with the Library\r
+creates an executable that is a derivative of the Library (because it\r
+contains portions of the Library), rather than a "work that uses the\r
+library".  The executable is therefore covered by this License.\r
+Section 6 states terms for distribution of such executables.\r
+\r
+  When a "work that uses the Library" uses material from a header file\r
+that is part of the Library, the object code for the work may be a\r
+derivative work of the Library even though the source code is not.\r
+Whether this is true is especially significant if the work can be\r
+linked without the Library, or if the work is itself a library.  The\r
+threshold for this to be true is not precisely defined by law.\r
+\r
+  If such an object file uses only numerical parameters, data\r
+structure layouts and accessors, and small macros and small inline\r
+functions (ten lines or less in length), then the use of the object\r
+file is unrestricted, regardless of whether it is legally a derivative\r
+work.  (Executables containing this object code plus portions of the\r
+Library will still fall under Section 6.)\r
+\r
+  Otherwise, if the work is a derivative of the Library, you may\r
+distribute the object code for the work under the terms of Section 6.\r
+Any executables containing that work also fall under Section 6,\r
+whether or not they are linked directly with the Library itself.\r
+\f\r
+  6. As an exception to the Sections above, you may also combine or\r
+link a "work that uses the Library" with the Library to produce a\r
+work containing portions of the Library, and distribute that work\r
+under terms of your choice, provided that the terms permit\r
+modification of the work for the customer's own use and reverse\r
+engineering for debugging such modifications.\r
+\r
+  You must give prominent notice with each copy of the work that the\r
+Library is used in it and that the Library and its use are covered by\r
+this License.  You must supply a copy of this License.  If the work\r
+during execution displays copyright notices, you must include the\r
+copyright notice for the Library among them, as well as a reference\r
+directing the user to the copy of this License.  Also, you must do one\r
+of these things:\r
+\r
+    a) Accompany the work with the complete corresponding\r
+    machine-readable source code for the Library including whatever\r
+    changes were used in the work (which must be distributed under\r
+    Sections 1 and 2 above); and, if the work is an executable linked\r
+    with the Library, with the complete machine-readable "work that\r
+    uses the Library", as object code and/or source code, so that the\r
+    user can modify the Library and then relink to produce a modified\r
+    executable containing the modified Library.  (It is understood\r
+    that the user who changes the contents of definitions files in the\r
+    Library will not necessarily be able to recompile the application\r
+    to use the modified definitions.)\r
+\r
+    b) Use a suitable shared library mechanism for linking with the\r
+    Library.  A suitable mechanism is one that (1) uses at run time a\r
+    copy of the library already present on the user's computer system,\r
+    rather than copying library functions into the executable, and (2)\r
+    will operate properly with a modified version of the library, if\r
+    the user installs one, as long as the modified version is\r
+    interface-compatible with the version that the work was made with.\r
+\r
+    c) Accompany the work with a written offer, valid for at\r
+    least three years, to give the same user the materials\r
+    specified in Subsection 6a, above, for a charge no more\r
+    than the cost of performing this distribution.\r
+\r
+    d) If distribution of the work is made by offering access to copy\r
+    from a designated place, offer equivalent access to copy the above\r
+    specified materials from the same place.\r
+\r
+    e) Verify that the user has already received a copy of these\r
+    materials or that you have already sent this user a copy.\r
+\r
+  For an executable, the required form of the "work that uses the\r
+Library" must include any data and utility programs needed for\r
+reproducing the executable from it.  However, as a special exception,\r
+the materials to be distributed need not include anything that is\r
+normally distributed (in either source or binary form) with the major\r
+components (compiler, kernel, and so on) of the operating system on\r
+which the executable runs, unless that component itself accompanies\r
+the executable.\r
+\r
+  It may happen that this requirement contradicts the license\r
+restrictions of other proprietary libraries that do not normally\r
+accompany the operating system.  Such a contradiction means you cannot\r
+use both them and the Library together in an executable that you\r
+distribute.\r
+\f\r
+  7. You may place library facilities that are a work based on the\r
+Library side-by-side in a single library together with other library\r
+facilities not covered by this License, and distribute such a combined\r
+library, provided that the separate distribution of the work based on\r
+the Library and of the other library facilities is otherwise\r
+permitted, and provided that you do these two things:\r
+\r
+    a) Accompany the combined library with a copy of the same work\r
+    based on the Library, uncombined with any other library\r
+    facilities.  This must be distributed under the terms of the\r
+    Sections above.\r
+\r
+    b) Give prominent notice with the combined library of the fact\r
+    that part of it is a work based on the Library, and explaining\r
+    where to find the accompanying uncombined form of the same work.\r
+\r
+  8. You may not copy, modify, sublicense, link with, or distribute\r
+the Library except as expressly provided under this License.  Any\r
+attempt otherwise to copy, modify, sublicense, link with, or\r
+distribute the Library is void, and will automatically terminate your\r
+rights under this License.  However, parties who have received copies,\r
+or rights, from you under this License will not have their licenses\r
+terminated so long as such parties remain in full compliance.\r
+\r
+  9. You are not required to accept this License, since you have not\r
+signed it.  However, nothing else grants you permission to modify or\r
+distribute the Library or its derivative works.  These actions are\r
+prohibited by law if you do not accept this License.  Therefore, by\r
+modifying or distributing the Library (or any work based on the\r
+Library), you indicate your acceptance of this License to do so, and\r
+all its terms and conditions for copying, distributing or modifying\r
+the Library or works based on it.\r
+\r
+  10. Each time you redistribute the Library (or any work based on the\r
+Library), the recipient automatically receives a license from the\r
+original licensor to copy, distribute, link with or modify the Library\r
+subject to these terms and conditions.  You may not impose any further\r
+restrictions on the recipients' exercise of the rights granted herein.\r
+You are not responsible for enforcing compliance by third parties with\r
+this License.\r
+\f\r
+  11. If, as a consequence of a court judgment or allegation of patent\r
+infringement or for any other reason (not limited to patent issues),\r
+conditions are imposed on you (whether by court order, agreement or\r
+otherwise) that contradict the conditions of this License, they do not\r
+excuse you from the conditions of this License.  If you cannot\r
+distribute so as to satisfy simultaneously your obligations under this\r
+License and any other pertinent obligations, then as a consequence you\r
+may not distribute the Library at all.  For example, if a patent\r
+license would not permit royalty-free redistribution of the Library by\r
+all those who receive copies directly or indirectly through you, then\r
+the only way you could satisfy both it and this License would be to\r
+refrain entirely from distribution of the Library.\r
+\r
+If any portion of this section is held invalid or unenforceable under any\r
+particular circumstance, the balance of the section is intended to apply,\r
+and the section as a whole is intended to apply in other circumstances.\r
+\r
+It is not the purpose of this section to induce you to infringe any\r
+patents or other property right claims or to contest validity of any\r
+such claims; this section has the sole purpose of protecting the\r
+integrity of the free software distribution system which is\r
+implemented by public license practices.  Many people have made\r
+generous contributions to the wide range of software distributed\r
+through that system in reliance on consistent application of that\r
+system; it is up to the author/donor to decide if he or she is willing\r
+to distribute software through any other system and a licensee cannot\r
+impose that choice.\r
+\r
+This section is intended to make thoroughly clear what is believed to\r
+be a consequence of the rest of this License.\r
+\r
+  12. If the distribution and/or use of the Library is restricted in\r
+certain countries either by patents or by copyrighted interfaces, the\r
+original copyright holder who places the Library under this License may add\r
+an explicit geographical distribution limitation excluding those countries,\r
+so that distribution is permitted only in or among countries not thus\r
+excluded.  In such case, this License incorporates the limitation as if\r
+written in the body of this License.\r
+\r
+  13. The Free Software Foundation may publish revised and/or new\r
+versions of the Lesser General Public License from time to time.\r
+Such new versions will be similar in spirit to the present version,\r
+but may differ in detail to address new problems or concerns.\r
+\r
+Each version is given a distinguishing version number.  If the Library\r
+specifies a version number of this License which applies to it and\r
+"any later version", you have the option of following the terms and\r
+conditions either of that version or of any later version published by\r
+the Free Software Foundation.  If the Library does not specify a\r
+license version number, you may choose any version ever published by\r
+the Free Software Foundation.\r
+\f\r
+  14. If you wish to incorporate parts of the Library into other free\r
+programs whose distribution conditions are incompatible with these,\r
+write to the author to ask for permission.  For software which is\r
+copyrighted by the Free Software Foundation, write to the Free\r
+Software Foundation; we sometimes make exceptions for this.  Our\r
+decision will be guided by the two goals of preserving the free status\r
+of all derivatives of our free software and of promoting the sharing\r
+and reuse of software generally.\r
+\r
+                           NO WARRANTY\r
+\r
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO\r
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.\r
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR\r
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY\r
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE\r
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE\r
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME\r
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\r
+\r
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN\r
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY\r
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU\r
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR\r
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE\r
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING\r
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A\r
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF\r
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
+DAMAGES.\r
+\r
+                    END OF TERMS AND CONDITIONS\r
+\f\r
+           How to Apply These Terms to Your New Libraries\r
+\r
+  If you develop a new library, and you want it to be of the greatest\r
+possible use to the public, we recommend making it free software that\r
+everyone can redistribute and change.  You can do so by permitting\r
+redistribution under these terms (or, alternatively, under the terms of the\r
+ordinary General Public License).\r
+\r
+  To apply these terms, attach the following notices to the library.  It is\r
+safest to attach them to the start of each source file to most effectively\r
+convey the exclusion of warranty; and each file should have at least the\r
+"copyright" line and a pointer to where the full notice is found.\r
+\r
+    <one line to give the library's name and a brief idea of what it does.>\r
+    Copyright (C) <year>  <name of author>\r
+\r
+    This library is free software; you can redistribute it and/or\r
+    modify it under the terms of the GNU Lesser General Public\r
+    License as published by the Free Software Foundation; either\r
+    version 2.1 of the License, or (at your option) any later version.\r
+\r
+    This library is distributed in the hope that it will be useful,\r
+    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+    Lesser General Public License for more details.\r
+\r
+    You should have received a copy of the GNU Lesser General Public\r
+    License along with this library; if not, write to the Free Software\r
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+\r
+Also add information on how to contact you by electronic and paper mail.\r
+\r
+You should also get your employer (if you work as a programmer) or your\r
+school, if any, to sign a "copyright disclaimer" for the library, if\r
+necessary.  Here is a sample; alter the names:\r
+\r
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the\r
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.\r
+\r
+  <signature of Ty Coon>, 1 April 1990\r
+  Ty Coon, President of Vice\r
+\r
+That's all there is to it!\r
+\r
+\r
index 6ab9e694cd302f4254c6cb38aeb1f194859c5d86..0644b7de50a432030b93cc6b210e1297d8b45b2e 100644 (file)
@@ -1,88 +1,88 @@
-using System;
-using System.Text;
-using System.Collections;
-
-namespace ByteFX.Data.MySqlClient
-{
-       /// <summary>
-       /// Summary description for CharSetMap.
-       /// </summary>
-       internal class CharSetMap
-       {
-               private static Hashtable mapping;
-
-               /// <summary>
-               /// 
-               /// </summary>
-               /// <param name="MySqlCharSetName"></param>
-               /// <returns></returns>
-               public static Encoding GetEncoding( string MySqlCharSetName ) 
-               {
-                       if (mapping == null )
-                               InitializeMapping();
-                       try 
-                       {
-                               int cpid = (int)mapping[ MySqlCharSetName ];
-                               return Encoding.GetEncoding( cpid );
-                       }
-                       catch (System.NotSupportedException) 
-                       {
-                               return Encoding.GetEncoding(0);
-                       }
-               }
-
-               /// <summary>
-               /// 
-               /// </summary>
-               private static void InitializeMapping() 
-               {
-                       mapping = new Hashtable();
-
-                       // relatively sure about
-                       mapping.Add( "default", 0 );
-                       mapping.Add( "big5", 950 );                     // Traditional Chinese
-                       mapping.Add( "latin1", 28591 );         // Latin alphabet #1
-                       mapping.Add( "utf8", 65001 );
-                       mapping.Add( "ucs2", 1200 );
-                       mapping.Add( "latin2", 28592 );
-                       mapping.Add( "latin4", 28594 );
-                       mapping.Add( "latin3", 28593 );
-                       mapping.Add( "latin5", 1254 );
-                       mapping.Add( "cp1251", 1251 );          // Russian
-                       mapping.Add( "win1251", 1251 );
-                       mapping.Add( "hebrew", 1255 );          // Hebrew
-                       mapping.Add( "greek", 1253 );           // Greek
-                       mapping.Add( "sjis", 932 );                     // Shift-JIS
-                       mapping.Add( "gbk", 936 );                      // Simplified Chinese
-                       mapping.Add( "cp866", 866 );
-                       mapping.Add( "euc_kr", 949 );
-
-                       // maybe, maybe not...
-                       mapping.Add( "win1250", 1250 );         // Central Eurpoe
-                       mapping.Add( "win1251ukr", 1251 );
-                       mapping.Add( "latin1_de", 1252 );       // Latin1 German
-                       mapping.Add( "german1", 1252 );         // German
-                       mapping.Add( "danish", 1252 );          // Danish
-                       mapping.Add( "dos", 437 );                      // Dos
-                       mapping.Add( "pclatin2", 852 );         
-                       mapping.Add( "win1250ch", 1250 );
-                       mapping.Add( "cp1257", 1257 );
-                       mapping.Add( "usa7", 646 );
-                       mapping.Add( "czech", 912 );
-                       mapping.Add( "hungarian", 912 );
-                       mapping.Add( "croat", 912 );
-
-/*                     ("gb2312", "EUC_CN");
-                       ("ujis", "EUC_JP");
-                       ("latvian", "ISO8859_13");
-                       ("latvian1", "ISO8859_13");
-                       ("estonia", "ISO8859_13");
-                       ("koi8_ru", "KOI8_R");
-                       ("tis620", "TIS620");
-                       ("macroman", "MacRoman");
-                       ("macce", "MacCentralEurope");
-*/
-
-               }
-       }
-}
+using System;\r
+using System.Text;\r
+using System.Collections;\r
+\r
+namespace ByteFX.Data.MySqlClient\r
+{\r
+       /// <summary>\r
+       /// Summary description for CharSetMap.\r
+       /// </summary>\r
+       internal class CharSetMap\r
+       {\r
+               private static Hashtable mapping;\r
+\r
+               /// <summary>\r
+               /// \r
+               /// </summary>\r
+               /// <param name="MySqlCharSetName"></param>\r
+               /// <returns></returns>\r
+               public static Encoding GetEncoding( string MySqlCharSetName ) \r
+               {\r
+                       if (mapping == null )\r
+                               InitializeMapping();\r
+                       try \r
+                       {\r
+                               int cpid = (int)mapping[ MySqlCharSetName ];\r
+                               return Encoding.GetEncoding( cpid );\r
+                       }\r
+                       catch (System.NotSupportedException) \r
+                       {\r
+                               return Encoding.GetEncoding(0);\r
+                       }\r
+               }\r
+\r
+               /// <summary>\r
+               /// \r
+               /// </summary>\r
+               private static void InitializeMapping() \r
+               {\r
+                       mapping = new Hashtable();\r
+\r
+                       // relatively sure about\r
+                       mapping.Add( "default", 0 );\r
+                       mapping.Add( "big5", 950 );                     // Traditional Chinese\r
+                       mapping.Add( "latin1", 28591 );         // Latin alphabet #1\r
+                       mapping.Add( "utf8", 65001 );\r
+                       mapping.Add( "ucs2", 1200 );\r
+                       mapping.Add( "latin2", 28592 );\r
+                       mapping.Add( "latin4", 28594 );\r
+                       mapping.Add( "latin3", 28593 );\r
+                       mapping.Add( "latin5", 1254 );\r
+                       mapping.Add( "cp1251", 1251 );          // Russian\r
+                       mapping.Add( "win1251", 1251 );\r
+                       mapping.Add( "hebrew", 1255 );          // Hebrew\r
+                       mapping.Add( "greek", 1253 );           // Greek\r
+                       mapping.Add( "sjis", 932 );                     // Shift-JIS\r
+                       mapping.Add( "gbk", 936 );                      // Simplified Chinese\r
+                       mapping.Add( "cp866", 866 );\r
+                       mapping.Add( "euc_kr", 949 );\r
+\r
+                       // maybe, maybe not...\r
+                       mapping.Add( "win1250", 1250 );         // Central Eurpoe\r
+                       mapping.Add( "win1251ukr", 1251 );\r
+                       mapping.Add( "latin1_de", 1252 );       // Latin1 German\r
+                       mapping.Add( "german1", 1252 );         // German\r
+                       mapping.Add( "danish", 1252 );          // Danish\r
+                       mapping.Add( "dos", 437 );                      // Dos\r
+                       mapping.Add( "pclatin2", 852 );         \r
+                       mapping.Add( "win1250ch", 1250 );\r
+                       mapping.Add( "cp1257", 1257 );\r
+                       mapping.Add( "usa7", 646 );\r
+                       mapping.Add( "czech", 912 );\r
+                       mapping.Add( "hungarian", 912 );\r
+                       mapping.Add( "croat", 912 );\r
+\r
+/*                     ("gb2312", "EUC_CN");\r
+                       ("ujis", "EUC_JP");\r
+                       ("latvian", "ISO8859_13");\r
+                       ("latvian1", "ISO8859_13");\r
+                       ("estonia", "ISO8859_13");\r
+                       ("koi8_ru", "KOI8_R");\r
+                       ("tis620", "TIS620");\r
+                       ("macroman", "MacRoman");\r
+                       ("macce", "MacCentralEurope");\r
+*/\r
+\r
+               }\r
+       }\r
+}\r
index 7572a398e4b2c71960e30bd37f0a841466ff61e6..00aaf58fa32a87de565e96a6b42b21ca7fb5c44d 100755 (executable)
-// ByteFX.Data data access components for .Net
-// Copyright (C) 2002-2003  ByteFX, Inc.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// 
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-// 
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-using System;
-using System.ComponentModel;
-using System.Data;
-using System.Text;
-
-namespace ByteFX.Data.MySqlClient
-{
-       /// <summary>
-       /// Automatically generates single-table commands used to reconcile changes made to a DataSet with the associated MySQL database. This class cannot be inherited.
-       /// </summary>
-       /// <include file='docs/MySqlCommandBuilder.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>
-       [ToolboxItem(false)]
-       [System.ComponentModel.DesignerCategory("Code")]
-       public sealed class MySqlCommandBuilder : Component
-       {
-               private MySqlDataAdapter        _adapter;
-               private string                          _QuotePrefix;
-               private string                          _QuoteSuffix;
-               private DataTable                       _schema;
-               private string                          _tableName;
-
-               private MySqlCommand            _updateCmd;
-               private MySqlCommand            _insertCmd;
-               private MySqlCommand            _deleteCmd;
-
-               #region Constructors
-               /// <summary>
-               /// Overloaded. Initializes a new instance of the SqlCommandBuilder class.
-               /// </summary>
-               public MySqlCommandBuilder()
-               {
-               }
-
-               /// <summary>
-               /// Overloaded. Initializes a new instance of the SqlCommandBuilder class.
-               /// </summary>
-               public MySqlCommandBuilder( MySqlDataAdapter adapter )
-               {
-                       _adapter = adapter;
-                       _adapter.RowUpdating += new MySqlRowUpdatingEventHandler( OnRowUpdating );
-               }
-               #endregion
-
-               #region Properties
-
-               /// <summary>
-               /// Gets or sets a MySqlDataAdapter object for which SQL statements are automatically generated.
-               /// </summary>
-               public MySqlDataAdapter DataAdapter 
-               {
-                       get { return _adapter; }
-                       set 
-                       { 
-                               if (_adapter != null) 
-                               {
-                                       _adapter.RowUpdating -= new MySqlRowUpdatingEventHandler( OnRowUpdating );
-                               }
-                               _adapter = value; 
-                       }
-               }
-
-               /// <summary>
-               /// Gets or sets the beginning character or characters to use when specifying MySql database objects (for example, tables or columns) whose names contain characters such as spaces or reserved tokens.
-               /// </summary>
-               public string QuotePrefix 
-               {
-                       get { return _QuotePrefix; }
-                       set { _QuotePrefix = value; }
-               }
-
-               /// <summary>
-               /// Gets or sets the ending character or characters to use when specifying MySql database objects (for example, tables or columns) whose names contain characters such as spaces or reserved tokens.
-               /// </summary>
-               public string QuoteSuffix
-               {
-                       get { return _QuoteSuffix; }
-                       set { _QuoteSuffix = value; }
-               }
-
-               #endregion
-
-               #region Public Methods
-               /// <summary>
-               /// Retrieves parameter information from the stored procedure specified in the MySqlCommand and populates the Parameters collection of the specified MySqlCommand object.
-               /// This method is not currently supported since stored procedures are not available in MySql.
-               /// </summary>
-               /// <param name="command">The MySqlCommand referencing the stored procedure from which the parameter information is to be derived. The derived parameters are added to the Parameters collection of the MySqlCommand.</param>
-               /// <exception cref="InvalidOperationException">The command text is not a valid stored procedure name.</exception>
-               public static void DeriveParameters(MySqlCommand command)
-               {
-                       throw new MySqlException("DeriveParameters is not supported (due to MySql not supporting SP)");
-               }
-
-               /// <summary>
-               /// Gets the automatically generated MySqlCommand object required to perform deletions on the database.
-               /// </summary>
-               /// <returns></returns>
-               public MySqlCommand GetDeleteCommand()
-               {
-                       if (_schema == null)
-                               GenerateSchema();
-                       return CreateDeleteCommand();
-               }
-
-               /// <summary>
-               /// Gets the automatically generated MySqlCommand object required to perform insertions on the database.
-               /// </summary>
-               /// <returns></returns>
-               public MySqlCommand GetInsertCommand()
-               {
-                       if (_schema == null)
-                               GenerateSchema();
-                       return CreateInsertCommand();
-               }
-
-               /// <summary>
-               /// Gets the automatically generated MySqlCommand object required to perform updates on the database.
-               /// </summary>
-               /// <returns></returns>
-               public MySqlCommand GetUpdateCommand() 
-               {
-                       if (_schema == null)
-                               GenerateSchema();
-                       return CreateUpdateCommand();
-               }
-
-               /// <summary>
-               /// Refreshes the database schema information used to generate INSERT, UPDATE, or DELETE statements.
-               /// </summary>
-               public void RefreshSchema()
-               {
-                       _schema = null;
-                       _insertCmd = null;
-                       _deleteCmd = null;
-                       _updateCmd = null;
-               }
-               #endregion
-
-               #region Private Methods
-
-               private void GenerateSchema()
-               {
-                       if (_adapter == null)
-                               throw new MySqlException("Improper MySqlCommandBuilder state: adapter is null");
-                       if (_adapter.SelectCommand == null)
-                               throw new MySqlException("Improper MySqlCommandBuilder state: adapter's SelectCommand is null");
-
-                       MySqlDataReader dr = _adapter.SelectCommand.ExecuteReader(CommandBehavior.SchemaOnly | CommandBehavior.KeyInfo);
-                       _schema = dr.GetSchemaTable();
-                       dr.Close();
-
-                       // make sure we got at least one unique or key field and count base table names
-                       bool   hasKeyOrUnique=false;
-
-                       foreach (DataRow row in _schema.Rows)
-                       {
-                               if (true == (bool)row["IsKey"] || true == (bool)row["IsUnique"])
-                                       hasKeyOrUnique=true;
-                               if (_tableName == null)
-                                       _tableName = (string)row["BaseTableName"];
-                               else if (_tableName != (string)row["BaseTableName"])
-                                       throw new InvalidOperationException("MySqlCommandBuilder does not support multi-table statements");
-                       }
-                       if (! hasKeyOrUnique)
-                               throw new InvalidOperationException("MySqlCommandBuilder cannot operate on tables with no unique or key columns");
-               }
-
-               private string Quote(string table_or_column)
-               {
-                       if (_QuotePrefix == null || _QuoteSuffix == null)
-                               return table_or_column;
-                       return _QuotePrefix + table_or_column + _QuoteSuffix;
-               }
-
-               private MySqlParameter CreateParameter(DataRow row, bool Original)
-               {
-                       MySqlParameter p;
-                       if (Original)
-                               p = new MySqlParameter( "@Original_" + (string)row["ColumnName"], (MySqlDbType)row["ProviderType"],
-                                       ParameterDirection.Input, (string)row["ColumnName"], DataRowVersion.Original, DBNull.Value );
-                       else
-                               p = new MySqlParameter( "@" + (string)row["ColumnName"], (MySqlDbType)row["ProviderType"],
-                                       ParameterDirection.Input, (string)row["ColumnName"], DataRowVersion.Current, DBNull.Value );
-                       return p;
-               }
-
-               private MySqlCommand CreateBaseCommand()
-               {
-                       MySqlCommand cmd = new MySqlCommand();
-                       cmd.Connection = _adapter.SelectCommand.Connection;
-                       cmd.CommandTimeout = _adapter.SelectCommand.CommandTimeout;
-                       cmd.Transaction = _adapter.SelectCommand.Transaction;
-                       return cmd;
-               }
-
-               private MySqlCommand CreateDeleteCommand()
-               {
-                       if (_deleteCmd != null) return _deleteCmd;
-
-                       MySqlCommand cmd = CreateBaseCommand();
-
-                       cmd.CommandText = "DELETE FROM " + Quote(_tableName) + 
-                               " WHERE " + CreateOriginalWhere(cmd);
-
-                       _deleteCmd = cmd;
-                       return cmd;
-               }
-
-               private string CreateFinalSelect(bool forinsert)
-               {
-                       StringBuilder sel = new StringBuilder();
-                       StringBuilder where = new StringBuilder();
-
-                       foreach (DataRow row in _schema.Rows)
-                       {
-                               string colname = (string)row["ColumnName"];
-                               if (sel.Length > 0)
-                                       sel.Append(", ");
-                               sel.Append( colname );
-                               if ((bool)row["IsKey"] == false) continue;
-                               if (where.Length > 0)
-                                       where.Append(" AND ");
-                               where.Append( "(" + colname + "=" );
-                               if (forinsert) 
-                               {
-                                       if ((bool)row["IsAutoIncrement"])
-                                               where.Append("last_insert_id()");
-                                       else if ((bool)row["IsKey"])
-                                               where.Append("@" + colname);
-                               }
-                               else 
-                               {
-                                       where.Append("@Original_" + colname);
-                               }
-                               where.Append(")");
-                       }
-                       return "SELECT " + sel.ToString() + " FROM " + Quote(_tableName) +
-                                  " WHERE " + where.ToString();
-               }
-
-               private string CreateOriginalWhere(MySqlCommand cmd)
-               {
-                       StringBuilder wherestr = new StringBuilder();
-
-                       foreach (DataRow row in _schema.Rows)
-                       {
-                               if (! IncludedInWhereClause(row)) continue;
-
-                               // first update the where clause since it will contain all parameters
-                               if (wherestr.Length > 0)
-                                       wherestr.Append(" AND ");
-                               string colname = Quote((string)row["ColumnName"]);
-
-                               MySqlParameter op = CreateParameter(row, true);
-                               cmd.Parameters.Add(op);
-
-                               wherestr.Append( "(" + colname + "=@" + op.ParameterName);
-                               if ((bool)row["AllowDBNull"] == true) 
-                                       wherestr.Append( " or (" + colname + " IS NULL and @" + op.ParameterName + " IS NULL)");
-                               wherestr.Append(")");
-                       }
-                       return wherestr.ToString();
-               }
-
-               private MySqlCommand CreateUpdateCommand()
-               {
-                       if (_updateCmd != null) return _updateCmd; 
-
-                       MySqlCommand cmd = CreateBaseCommand();
-
-                       StringBuilder setstr = new StringBuilder();
-               
-                       foreach (DataRow schemaRow in _schema.Rows)
-                       {
-                               string colname = Quote((string)schemaRow["ColumnName"]);
-
-                               if (! IncludedInUpdate(schemaRow)) continue;
-
-                               if (setstr.Length > 0) 
-                                       setstr.Append(", ");
-
-                               MySqlParameter p = CreateParameter(schemaRow, false);
-                               cmd.Parameters.Add(p);
-
-                               setstr.Append( colname + "=@" + p.ParameterName );
-                       }
-
-                       cmd.CommandText = "UPDATE " + Quote(_tableName) + " SET " + setstr.ToString() + 
-                                                         " WHERE " + CreateOriginalWhere(cmd);
-                       cmd.CommandText += "; " + CreateFinalSelect(false);
-
-                       _updateCmd = cmd;
-                       return cmd;
-               }
-
-               private MySqlCommand CreateInsertCommand()
-               {
-                       if (_insertCmd != null) return _insertCmd;
-
-                       MySqlCommand cmd = CreateBaseCommand();
-
-                       StringBuilder setstr = new StringBuilder();
-                       StringBuilder valstr = new StringBuilder();
-                       foreach (DataRow schemaRow in _schema.Rows)
-                       {
-                               string colname = Quote((string)schemaRow["ColumnName"]);
-
-                               if (!IncludedInInsert(schemaRow)) continue;
-
-                               if (setstr.Length > 0) 
-                               {
-                                       setstr.Append(", ");
-                                       valstr.Append(", ");
-                               }
-
-                               MySqlParameter p = CreateParameter(schemaRow, false);
-                               cmd.Parameters.Add(p);
-
-                               setstr.Append( colname );
-                               valstr.Append( "@" + p.ParameterName );
-                       }
-
-                       cmd.CommandText = "INSERT INTO " + Quote(_tableName) + " (" + setstr.ToString() + ") " +
-                               " VALUES (" + valstr.ToString() + ")";
-                       cmd.CommandText += "; " + CreateFinalSelect(true);
-
-                       _insertCmd = cmd;
-                       return cmd;
-               }
-
-               private bool IncludedInInsert (DataRow schemaRow)
-               {
-                       // If the parameter has one of these properties, then we don't include it in the insert:
-                       // AutoIncrement, Hidden, Expression, RowVersion, ReadOnly
-
-                       if ((bool) schemaRow ["IsAutoIncrement"])
-                               return false;
-/*                     if ((bool) schemaRow ["IsHidden"])
-                               return false;
-                       if ((bool) schemaRow ["IsExpression"])
-                               return false;*/
-                       if ((bool) schemaRow ["IsRowVersion"])
-                               return false;
-                       if ((bool) schemaRow ["IsReadOnly"])
-                               return false;
-                       return true;
-               }
-
-               private bool IncludedInUpdate (DataRow schemaRow)
-               {
-                       // If the parameter has one of these properties, then we don't include it in the insert:
-                       // AutoIncrement, Hidden, RowVersion
-
-                       if ((bool) schemaRow ["IsAutoIncrement"])
-                               return false;
-//                     if ((bool) schemaRow ["IsHidden"])
-//                             return false;
-                       if ((bool) schemaRow ["IsRowVersion"])
-                               return false;
-                       return true;
-               }
-
-               private bool IncludedInWhereClause (DataRow schemaRow)
-               {
-//                     if ((bool) schemaRow ["IsLong"])
-//                             return false;
-                       return true;
-               }
-
-               private void SetParameterValues(MySqlCommand cmd, DataRow dataRow)
-               {
-                       foreach (MySqlParameter p in cmd.Parameters)
-                       {
-                               if (p.ParameterName.Length >= 8 && p.ParameterName.Substring(0, 8).Equals("Original"))
-                                       p.Value = dataRow[ p.SourceColumn, DataRowVersion.Original ];
-                               else
-                                       p.Value = dataRow[ p.SourceColumn, DataRowVersion.Current ];
-                       }
-               }
-
-               private void OnRowUpdating(object sender, MySqlRowUpdatingEventArgs args)
-               {
-                       // make sure we are still to proceed
-                       if (args.Status != UpdateStatus.Continue) return;
-
-                       if (_schema == null)
-                               GenerateSchema();
-
-                       if (StatementType.Delete == args.StatementType)
-                               args.Command = CreateDeleteCommand();
-                       else if (StatementType.Update == args.StatementType)
-                               args.Command = CreateUpdateCommand();
-                       else if (StatementType.Insert == args.StatementType)
-                               args.Command = CreateInsertCommand();
-                       else if (StatementType.Select == args.StatementType)
-                               return;
-
-                       SetParameterValues(args.Command, args.Row);
-               }
-               #endregion
-
-       }
-}
+// ByteFX.Data data access components for .Net\r
+// Copyright (C) 2002-2003  ByteFX, Inc.\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License, or (at your option) any later version.\r
+// \r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+// Lesser General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+\r
+using System;\r
+using System.ComponentModel;\r
+using System.Data;\r
+using System.Text;\r
+\r
+namespace ByteFX.Data.MySqlClient\r
+{\r
+       /// <summary>\r
+       /// Automatically generates single-table commands used to reconcile changes made to a DataSet with the associated MySQL database. This class cannot be inherited.\r
+       /// </summary>\r
+       /// <include file='docs/MySqlCommandBuilder.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>\r
+       [ToolboxItem(false)]\r
+       [System.ComponentModel.DesignerCategory("Code")]\r
+       public sealed class MySqlCommandBuilder : Component\r
+       {\r
+               private MySqlDataAdapter        _adapter;\r
+               private string                          _QuotePrefix;\r
+               private string                          _QuoteSuffix;\r
+               private DataTable                       _schema;\r
+               private string                          _tableName;\r
+\r
+               private MySqlCommand            _updateCmd;\r
+               private MySqlCommand            _insertCmd;\r
+               private MySqlCommand            _deleteCmd;\r
+\r
+               #region Constructors\r
+               /// <summary>\r
+               /// Overloaded. Initializes a new instance of the SqlCommandBuilder class.\r
+               /// </summary>\r
+               public MySqlCommandBuilder()\r
+               {\r
+               }\r
+\r
+               /// <summary>\r
+               /// Overloaded. Initializes a new instance of the SqlCommandBuilder class.\r
+               /// </summary>\r
+               public MySqlCommandBuilder( MySqlDataAdapter adapter )\r
+               {\r
+                       _adapter = adapter;\r
+                       _adapter.RowUpdating += new MySqlRowUpdatingEventHandler( OnRowUpdating );\r
+               }\r
+               #endregion\r
+\r
+               #region Properties\r
+\r
+               /// <summary>\r
+               /// Gets or sets a MySqlDataAdapter object for which SQL statements are automatically generated.\r
+               /// </summary>\r
+               public MySqlDataAdapter DataAdapter \r
+               {\r
+                       get { return _adapter; }\r
+                       set \r
+                       { \r
+                               if (_adapter != null) \r
+                               {\r
+                                       _adapter.RowUpdating -= new MySqlRowUpdatingEventHandler( OnRowUpdating );\r
+                               }\r
+                               _adapter = value; \r
+                       }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets or sets the beginning character or characters to use when specifying MySql database objects (for example, tables or columns) whose names contain characters such as spaces or reserved tokens.\r
+               /// </summary>\r
+               public string QuotePrefix \r
+               {\r
+                       get { return _QuotePrefix; }\r
+                       set { _QuotePrefix = value; }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets or sets the ending character or characters to use when specifying MySql database objects (for example, tables or columns) whose names contain characters such as spaces or reserved tokens.\r
+               /// </summary>\r
+               public string QuoteSuffix\r
+               {\r
+                       get { return _QuoteSuffix; }\r
+                       set { _QuoteSuffix = value; }\r
+               }\r
+\r
+               #endregion\r
+\r
+               #region Public Methods\r
+               /// <summary>\r
+               /// Retrieves parameter information from the stored procedure specified in the MySqlCommand and populates the Parameters collection of the specified MySqlCommand object.\r
+               /// This method is not currently supported since stored procedures are not available in MySql.\r
+               /// </summary>\r
+               /// <param name="command">The MySqlCommand referencing the stored procedure from which the parameter information is to be derived. The derived parameters are added to the Parameters collection of the MySqlCommand.</param>\r
+               /// <exception cref="InvalidOperationException">The command text is not a valid stored procedure name.</exception>\r
+               public static void DeriveParameters(MySqlCommand command)\r
+               {\r
+                       throw new MySqlException("DeriveParameters is not supported (due to MySql not supporting SP)");\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the automatically generated MySqlCommand object required to perform deletions on the database.\r
+               /// </summary>\r
+               /// <returns></returns>\r
+               public MySqlCommand GetDeleteCommand()\r
+               {\r
+                       if (_schema == null)\r
+                               GenerateSchema();\r
+                       return CreateDeleteCommand();\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the automatically generated MySqlCommand object required to perform insertions on the database.\r
+               /// </summary>\r
+               /// <returns></returns>\r
+               public MySqlCommand GetInsertCommand()\r
+               {\r
+                       if (_schema == null)\r
+                               GenerateSchema();\r
+                       return CreateInsertCommand();\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the automatically generated MySqlCommand object required to perform updates on the database.\r
+               /// </summary>\r
+               /// <returns></returns>\r
+               public MySqlCommand GetUpdateCommand() \r
+               {\r
+                       if (_schema == null)\r
+                               GenerateSchema();\r
+                       return CreateUpdateCommand();\r
+               }\r
+\r
+               /// <summary>\r
+               /// Refreshes the database schema information used to generate INSERT, UPDATE, or DELETE statements.\r
+               /// </summary>\r
+               public void RefreshSchema()\r
+               {\r
+                       _schema = null;\r
+                       _insertCmd = null;\r
+                       _deleteCmd = null;\r
+                       _updateCmd = null;\r
+               }\r
+               #endregion\r
+\r
+               #region Private Methods\r
+\r
+               private void GenerateSchema()\r
+               {\r
+                       if (_adapter == null)\r
+                               throw new MySqlException("Improper MySqlCommandBuilder state: adapter is null");\r
+                       if (_adapter.SelectCommand == null)\r
+                               throw new MySqlException("Improper MySqlCommandBuilder state: adapter's SelectCommand is null");\r
+\r
+                       MySqlDataReader dr = _adapter.SelectCommand.ExecuteReader(CommandBehavior.SchemaOnly | CommandBehavior.KeyInfo);\r
+                       _schema = dr.GetSchemaTable();\r
+                       dr.Close();\r
+\r
+                       // make sure we got at least one unique or key field and count base table names\r
+                       bool   hasKeyOrUnique=false;\r
+\r
+                       foreach (DataRow row in _schema.Rows)\r
+                       {\r
+                               if (true == (bool)row["IsKey"] || true == (bool)row["IsUnique"])\r
+                                       hasKeyOrUnique=true;\r
+                               if (_tableName == null)\r
+                                       _tableName = (string)row["BaseTableName"];\r
+                               else if (_tableName != (string)row["BaseTableName"])\r
+                                       throw new InvalidOperationException("MySqlCommandBuilder does not support multi-table statements");\r
+                       }\r
+                       if (! hasKeyOrUnique)\r
+                               throw new InvalidOperationException("MySqlCommandBuilder cannot operate on tables with no unique or key columns");\r
+               }\r
+\r
+               private string Quote(string table_or_column)\r
+               {\r
+                       if (_QuotePrefix == null || _QuoteSuffix == null)\r
+                               return table_or_column;\r
+                       return _QuotePrefix + table_or_column + _QuoteSuffix;\r
+               }\r
+\r
+               private MySqlParameter CreateParameter(DataRow row, bool Original)\r
+               {\r
+                       MySqlParameter p;\r
+                       if (Original)\r
+                               p = new MySqlParameter( "@Original_" + (string)row["ColumnName"], (MySqlDbType)row["ProviderType"],\r
+                                       ParameterDirection.Input, (string)row["ColumnName"], DataRowVersion.Original, DBNull.Value );\r
+                       else\r
+                               p = new MySqlParameter( "@" + (string)row["ColumnName"], (MySqlDbType)row["ProviderType"],\r
+                                       ParameterDirection.Input, (string)row["ColumnName"], DataRowVersion.Current, DBNull.Value );\r
+                       return p;\r
+               }\r
+\r
+               private MySqlCommand CreateBaseCommand()\r
+               {\r
+                       MySqlCommand cmd = new MySqlCommand();\r
+                       cmd.Connection = _adapter.SelectCommand.Connection;\r
+                       cmd.CommandTimeout = _adapter.SelectCommand.CommandTimeout;\r
+                       cmd.Transaction = _adapter.SelectCommand.Transaction;\r
+                       return cmd;\r
+               }\r
+\r
+               private MySqlCommand CreateDeleteCommand()\r
+               {\r
+                       if (_deleteCmd != null) return _deleteCmd;\r
+\r
+                       MySqlCommand cmd = CreateBaseCommand();\r
+\r
+                       cmd.CommandText = "DELETE FROM " + Quote(_tableName) + \r
+                               " WHERE " + CreateOriginalWhere(cmd);\r
+\r
+                       _deleteCmd = cmd;\r
+                       return cmd;\r
+               }\r
+\r
+               private string CreateFinalSelect(bool forinsert)\r
+               {\r
+                       StringBuilder sel = new StringBuilder();\r
+                       StringBuilder where = new StringBuilder();\r
+\r
+                       foreach (DataRow row in _schema.Rows)\r
+                       {\r
+                               string colname = (string)row["ColumnName"];\r
+                               if (sel.Length > 0)\r
+                                       sel.Append(", ");\r
+                               sel.Append( colname );\r
+                               if ((bool)row["IsKey"] == false) continue;\r
+                               if (where.Length > 0)\r
+                                       where.Append(" AND ");\r
+                               where.Append( "(" + colname + "=" );\r
+                               if (forinsert) \r
+                               {\r
+                                       if ((bool)row["IsAutoIncrement"])\r
+                                               where.Append("last_insert_id()");\r
+                                       else if ((bool)row["IsKey"])\r
+                                               where.Append("@" + colname);\r
+                               }\r
+                               else \r
+                               {\r
+                                       where.Append("@Original_" + colname);\r
+                               }\r
+                               where.Append(")");\r
+                       }\r
+                       return "SELECT " + sel.ToString() + " FROM " + Quote(_tableName) +\r
+                                  " WHERE " + where.ToString();\r
+               }\r
+\r
+               private string CreateOriginalWhere(MySqlCommand cmd)\r
+               {\r
+                       StringBuilder wherestr = new StringBuilder();\r
+\r
+                       foreach (DataRow row in _schema.Rows)\r
+                       {\r
+                               if (! IncludedInWhereClause(row)) continue;\r
+\r
+                               // first update the where clause since it will contain all parameters\r
+                               if (wherestr.Length > 0)\r
+                                       wherestr.Append(" AND ");\r
+                               string colname = Quote((string)row["ColumnName"]);\r
+\r
+                               MySqlParameter op = CreateParameter(row, true);\r
+                               cmd.Parameters.Add(op);\r
+\r
+                               wherestr.Append( "(" + colname + "=@" + op.ParameterName);\r
+                               if ((bool)row["AllowDBNull"] == true) \r
+                                       wherestr.Append( " or (" + colname + " IS NULL and @" + op.ParameterName + " IS NULL)");\r
+                               wherestr.Append(")");\r
+                       }\r
+                       return wherestr.ToString();\r
+               }\r
+\r
+               private MySqlCommand CreateUpdateCommand()\r
+               {\r
+                       if (_updateCmd != null) return _updateCmd; \r
+\r
+                       MySqlCommand cmd = CreateBaseCommand();\r
+\r
+                       StringBuilder setstr = new StringBuilder();\r
+               \r
+                       foreach (DataRow schemaRow in _schema.Rows)\r
+                       {\r
+                               string colname = Quote((string)schemaRow["ColumnName"]);\r
+\r
+                               if (! IncludedInUpdate(schemaRow)) continue;\r
+\r
+                               if (setstr.Length > 0) \r
+                                       setstr.Append(", ");\r
+\r
+                               MySqlParameter p = CreateParameter(schemaRow, false);\r
+                               cmd.Parameters.Add(p);\r
+\r
+                               setstr.Append( colname + "=@" + p.ParameterName );\r
+                       }\r
+\r
+                       cmd.CommandText = "UPDATE " + Quote(_tableName) + " SET " + setstr.ToString() + \r
+                                                         " WHERE " + CreateOriginalWhere(cmd);\r
+                       cmd.CommandText += "; " + CreateFinalSelect(false);\r
+\r
+                       _updateCmd = cmd;\r
+                       return cmd;\r
+               }\r
+\r
+               private MySqlCommand CreateInsertCommand()\r
+               {\r
+                       if (_insertCmd != null) return _insertCmd;\r
+\r
+                       MySqlCommand cmd = CreateBaseCommand();\r
+\r
+                       StringBuilder setstr = new StringBuilder();\r
+                       StringBuilder valstr = new StringBuilder();\r
+                       foreach (DataRow schemaRow in _schema.Rows)\r
+                       {\r
+                               string colname = Quote((string)schemaRow["ColumnName"]);\r
+\r
+                               if (!IncludedInInsert(schemaRow)) continue;\r
+\r
+                               if (setstr.Length > 0) \r
+                               {\r
+                                       setstr.Append(", ");\r
+                                       valstr.Append(", ");\r
+                               }\r
+\r
+                               MySqlParameter p = CreateParameter(schemaRow, false);\r
+                               cmd.Parameters.Add(p);\r
+\r
+                               setstr.Append( colname );\r
+                               valstr.Append( "@" + p.ParameterName );\r
+                       }\r
+\r
+                       cmd.CommandText = "INSERT INTO " + Quote(_tableName) + " (" + setstr.ToString() + ") " +\r
+                               " VALUES (" + valstr.ToString() + ")";\r
+                       cmd.CommandText += "; " + CreateFinalSelect(true);\r
+\r
+                       _insertCmd = cmd;\r
+                       return cmd;\r
+               }\r
+\r
+               private bool IncludedInInsert (DataRow schemaRow)\r
+               {\r
+                       // If the parameter has one of these properties, then we don't include it in the insert:\r
+                       // AutoIncrement, Hidden, Expression, RowVersion, ReadOnly\r
+\r
+                       if ((bool) schemaRow ["IsAutoIncrement"])\r
+                               return false;\r
+/*                     if ((bool) schemaRow ["IsHidden"])\r
+                               return false;\r
+                       if ((bool) schemaRow ["IsExpression"])\r
+                               return false;*/\r
+                       if ((bool) schemaRow ["IsRowVersion"])\r
+                               return false;\r
+                       if ((bool) schemaRow ["IsReadOnly"])\r
+                               return false;\r
+                       return true;\r
+               }\r
+\r
+               private bool IncludedInUpdate (DataRow schemaRow)\r
+               {\r
+                       // If the parameter has one of these properties, then we don't include it in the insert:\r
+                       // AutoIncrement, Hidden, RowVersion\r
+\r
+                       if ((bool) schemaRow ["IsAutoIncrement"])\r
+                               return false;\r
+//                     if ((bool) schemaRow ["IsHidden"])\r
+//                             return false;\r
+                       if ((bool) schemaRow ["IsRowVersion"])\r
+                               return false;\r
+                       return true;\r
+               }\r
+\r
+               private bool IncludedInWhereClause (DataRow schemaRow)\r
+               {\r
+//                     if ((bool) schemaRow ["IsLong"])\r
+//                             return false;\r
+                       return true;\r
+               }\r
+\r
+               private void SetParameterValues(MySqlCommand cmd, DataRow dataRow)\r
+               {\r
+                       foreach (MySqlParameter p in cmd.Parameters)\r
+                       {\r
+                               if (p.ParameterName.Length >= 8 && p.ParameterName.Substring(0, 8).Equals("Original"))\r
+                                       p.Value = dataRow[ p.SourceColumn, DataRowVersion.Original ];\r
+                               else\r
+                                       p.Value = dataRow[ p.SourceColumn, DataRowVersion.Current ];\r
+                       }\r
+               }\r
+\r
+               private void OnRowUpdating(object sender, MySqlRowUpdatingEventArgs args)\r
+               {\r
+                       // make sure we are still to proceed\r
+                       if (args.Status != UpdateStatus.Continue) return;\r
+\r
+                       if (_schema == null)\r
+                               GenerateSchema();\r
+\r
+                       if (StatementType.Delete == args.StatementType)\r
+                               args.Command = CreateDeleteCommand();\r
+                       else if (StatementType.Update == args.StatementType)\r
+                               args.Command = CreateUpdateCommand();\r
+                       else if (StatementType.Insert == args.StatementType)\r
+                               args.Command = CreateInsertCommand();\r
+                       else if (StatementType.Select == args.StatementType)\r
+                               return;\r
+\r
+                       SetParameterValues(args.Command, args.Row);\r
+               }\r
+               #endregion\r
+\r
+       }\r
+}\r
diff --git a/mcs/class/ByteFX.Data/mysqlclient/CommandResult.cs b/mcs/class/ByteFX.Data/mysqlclient/CommandResult.cs
new file mode 100644 (file)
index 0000000..29e1adc
--- /dev/null
@@ -0,0 +1,141 @@
+using System;\r
+\r
+namespace ByteFX.Data.MySqlClient\r
+{\r
+       /// <summary>\r
+       /// Summary description for CommandResult.\r
+       /// </summary>\r
+       internal class CommandResult\r
+       {\r
+               private Driver  driver;\r
+               private Packet  packet;\r
+               private int             affectedRows = -1;\r
+               private int             fieldCount = -1;\r
+               private int             fieldsRead = 0;\r
+               private long    fieldLength = 0;\r
+               private bool    readSchema = false;\r
+               private bool    readRows = false;\r
+\r
+               public CommandResult(Packet p, Driver d)\r
+               {\r
+                       driver = d;\r
+                       packet = p;\r
+                       fieldCount = (int)p.ReadLenInteger();\r
+                       if (fieldCount == 0)\r
+                               affectedRows =(int)p.ReadLenInteger();\r
+               }\r
+\r
+               #region Properties\r
+               public bool IsResultSet \r
+               {\r
+                       get { return fieldCount > 0; }\r
+               }\r
+\r
+               public int ColumnCount \r
+               {\r
+                       get { return fieldCount; }\r
+               }\r
+\r
+               public int RowsAffected\r
+               {\r
+                       get { return affectedRows; }\r
+               }\r
+\r
+               #endregion\r
+\r
+               public MySqlField GetField()\r
+               {\r
+                       MySqlField f = new MySqlField( driver.Encoding );\r
+                       packet = driver.ReadPacket();\r
+\r
+                       f.TableName = packet.ReadLenString();\r
+                       f.ColumnName = packet.ReadLenString();\r
+                       f.ColumnLength = (int)packet.ReadNBytes();\r
+                       f.Type = (MySqlDbType)packet.ReadNBytes();\r
+                       packet.ReadByte();                                                                      // this is apparently 2 -- not sure what it is for\r
+                       f.Flags = (ColumnFlags)packet.ReadInteger(2);           //(short)(d.ReadByte() & 0xff);\r
+                       f.NumericScale = packet.ReadByte();\r
+                       fieldsRead++;\r
+                       return f;\r
+               }\r
+\r
+               public byte[] GetFieldBuffer()\r
+               {\r
+                       return packet.GetBuffer();\r
+               }\r
+\r
+               public int GetFieldIndex()\r
+               {\r
+                       return (int)packet.Position;\r
+               }\r
+\r
+               public long GetFieldLength()\r
+               {\r
+                       return fieldLength;\r
+               }\r
+\r
+               public bool NextField()\r
+               {\r
+                       if (fieldLength >= 0)\r
+                               packet.Position += fieldLength;\r
+                       if (! packet.HasMoreData) return false;\r
+                       fieldLength = packet.ReadLenInteger();\r
+                       fieldsRead++;\r
+                       return true;\r
+               }\r
+\r
+\r
+               /// <summary>\r
+               /// Checks to see if there are any row packets coming\r
+               /// </summary>\r
+               /// <returns>True if there are row packets available, false if not</returns>\r
+               public bool CheckForRows()\r
+               {\r
+                       // first read off any unread field defs\r
+                       while (fieldsRead < fieldCount)\r
+                               GetField();\r
+\r
+                       // read off the end of schema packet\r
+                       packet = driver.ReadPacket();\r
+                       if ( ! packet.IsLastPacket())\r
+                               throw new MySqlException("Expected end of schema packet");\r
+                       readSchema = true;\r
+\r
+                       packet = driver.PeekPacket();\r
+                       return ! packet.IsLastPacket();\r
+               }\r
+\r
+               public bool ReadDataRow()\r
+               {\r
+                       packet = driver.ReadPacket();\r
+                       if (packet.IsLastPacket())\r
+                       {\r
+                               readRows = true;\r
+                               return false;\r
+                       }\r
+                       fieldsRead = 0;\r
+                       fieldLength = 0;\r
+                       NextField();\r
+                       return true;\r
+               }\r
+\r
+               public void Clear()\r
+               {\r
+                       Packet p;\r
+\r
+                       if (! readSchema)\r
+                       {\r
+                               do \r
+                               {\r
+                                       p = driver.ReadPacket();\r
+                               } while (! p.IsLastPacket());\r
+                       }\r
+\r
+                       if (! readRows)\r
+                               do \r
+                               {\r
+                                       p = driver.ReadPacket();\r
+                               } while (! p.IsLastPacket());\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/ByteFX.Data/mysqlclient/CompressedStream.cs b/mcs/class/ByteFX.Data/mysqlclient/CompressedStream.cs
new file mode 100644 (file)
index 0000000..544c51e
--- /dev/null
@@ -0,0 +1,155 @@
+using System;\r
+using System.IO;\r
+using ICSharpCode.SharpZipLib.Zip.Compression.Streams;\r
+\r
+namespace ByteFX.Data.MySqlClient\r
+{\r
+       /// <summary>\r
+       /// Summary description for CompressedStream.\r
+       /// </summary>\r
+       internal class CompressedStream : Stream\r
+       {\r
+               private Stream  srcStream;\r
+               private byte[]  buffer;\r
+               private int             index;\r
+\r
+               public CompressedStream( Stream src )\r
+               {\r
+                       srcStream = src;\r
+                       index = 0;\r
+                       buffer = new byte[0];\r
+               }\r
+\r
+               #region Properties\r
+               public override bool CanRead\r
+               {\r
+                       get     { return srcStream.CanRead; }\r
+               }\r
+\r
+               public override bool CanWrite\r
+               {\r
+                       get     { return srcStream.CanWrite; }\r
+               }\r
+\r
+               public override bool CanSeek\r
+               {\r
+                       get     { return srcStream.CanSeek; }\r
+               }\r
+\r
+               public override long Length\r
+               {\r
+                       get { return srcStream.Length; }\r
+               }\r
+\r
+               public override long Position\r
+               {\r
+                       get     { return srcStream.Position; }\r
+                       set     { srcStream.Position = value; }\r
+               }\r
+               #endregion\r
+\r
+               public override void Close()\r
+               {\r
+                       srcStream.Close();\r
+                       base.Close ();\r
+               }\r
+\r
+               public override void Flush()\r
+               {\r
+                       srcStream.Flush();\r
+               }\r
+\r
+               public override void SetLength(long value)\r
+               {\r
+                       srcStream.SetLength( value );\r
+               }\r
+\r
+               public override int ReadByte()\r
+               {\r
+                       EnsureData(1);\r
+\r
+                       return (int)buffer[index++];\r
+               }\r
+\r
+               public override int Read(byte[] buffer, int offset, int count)\r
+               {\r
+                       if (buffer == null)\r
+                               throw new ArgumentNullException( "buffer", "Buffer must not be null" );\r
+                       if (offset < 0 || offset >= buffer.Length)\r
+                               throw new ArgumentOutOfRangeException( "Offset must be a valid position in buffer" );\r
+                       if ((offset + count) > buffer.Length)\r
+                               throw new ArgumentException( "Buffer is not large enough to complete operation" );\r
+\r
+                       EnsureData( count );\r
+\r
+                       for (int i=0; i < count; i++)\r
+                               buffer[offset+i] = this.buffer[index++];\r
+\r
+                       return count;\r
+               }\r
+\r
+               public override void Write(byte[] buffer, int offset, int count)\r
+               {\r
+                       srcStream.Write( buffer, offset, count );\r
+               }\r
+\r
+               public override long Seek(long offset, SeekOrigin origin)\r
+               {\r
+                       return srcStream.Seek( offset, origin );\r
+               }\r
+\r
+               private void ReadBuffer( Stream s, byte[] buf, int offset, int length )\r
+               {\r
+                       while (length > 0)\r
+                       {\r
+                               int amountRead = s.Read( buf, offset, length );\r
+                               if (amountRead == 0)\r
+                               throw new MySqlException("Unexpected end of data encountered");\r
+                               length -= amountRead;\r
+                               offset += amountRead;\r
+                       }\r
+               }\r
+\r
+               private void ReadNextPacket()\r
+               {\r
+                       // read off the uncompressed and compressed lengths\r
+                       int compressedLen = srcStream.ReadByte() + (srcStream.ReadByte() << 8) + \r
+                               (srcStream.ReadByte() << 16);\r
+                       byte seq = (byte)srcStream.ReadByte();\r
+                       int unCompressedLen = srcStream.ReadByte() + (srcStream.ReadByte() << 8) + \r
+                               (srcStream.ReadByte() << 16);\r
+\r
+                       // if the data is in fact compressed, then uncompress it\r
+                       byte[] unCompressedBuffer = null;\r
+                       if (unCompressedLen > 0) \r
+                       {\r
+                               unCompressedBuffer = new byte[ unCompressedLen ];\r
+                               InflaterInputStream iis = new InflaterInputStream( srcStream );\r
+                               ReadBuffer( iis, unCompressedBuffer, 0, unCompressedLen );\r
+                       }\r
+                       else \r
+                       {\r
+                               unCompressedBuffer = new byte[ compressedLen ];\r
+                               ReadBuffer( srcStream, unCompressedBuffer, 0, compressedLen );\r
+                       }\r
+\r
+                       // now join this buffer to our existing one\r
+                       int left = buffer.Length - index;\r
+                       byte[] newBuffer = new byte[ left + unCompressedBuffer.Length ];\r
+\r
+                       int newIndex = 0;\r
+                       // first copy in the rest of the original\r
+                       for (int i=index; i < buffer.Length; i++)\r
+                               newBuffer[newIndex++] = buffer[i];\r
+                       unCompressedBuffer.CopyTo( newBuffer, newIndex );\r
+                       buffer = newBuffer;\r
+                       index = 0;\r
+               }\r
+\r
+               private void EnsureData( int size )\r
+               {\r
+                       while ((buffer.Length - index) < size)\r
+                               ReadNextPacket();\r
+               }\r
+       }\r
+}\r
index 47895e40d6e50163e998b1fe028d3ab60e07efec..3f0842897bf4a2474eb8617ad52128ada71cca62 100755 (executable)
-// ByteFX.Data data access components for .Net
-// Copyright (C) 2002-2003  ByteFX, Inc.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// 
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-// 
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-using System;
-using System.Data;
-using System.Collections.Specialized;
-using System.Text;
-using System.ComponentModel;
-using System.Globalization;
-using ByteFX.Data.Common;
-
-namespace ByteFX.Data.MySqlClient
-{
-       /// <summary>
-       /// Represents an open connection to a MySQL Server database. This class cannot be inherited.
-       /// </summary>
-       /// <include file='docs/MySqlConnection.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>
-       [System.Drawing.ToolboxBitmap( typeof(MySqlConnection), "Designers.connection.bmp")]
-       [System.ComponentModel.DesignerCategory("Code")]
-       [ToolboxItem(true)]
-       public sealed class MySqlConnection : Component, IDbConnection, ICloneable
-       {
-               internal ConnectionState                        state;
-               private  MySqlInternalConnection        internalConnection;
-               private  MySqlDataReader                        dataReader;
-               private  NumberFormatInfo                       numberFormat;
-               private  MySqlConnectionString          settings;
-
-               /// <summary>
-               /// Occurs when the state of the connection changes.
-               /// </summary>
-               public event StateChangeEventHandler    StateChange;
-
-
-               /// <summary>
-               /// Creates a new connection
-               /// </summary>
-               public MySqlConnection()
-               {
-                       settings = new MySqlConnectionString();
-               }
-
-               /// <summary>
-               /// Creates a new connection
-               /// </summary>
-               /// <param name="container"></param>
-               public MySqlConnection(System.ComponentModel.IContainer container)
-               {
-                       settings = new MySqlConnectionString();
-               }
-    
-
-               // Have a constructor that takes a connection string.
-               /// <summary>
-               /// Creates a new connection using the specified connection string.
-               /// </summary>
-               /// <param name="connectString"></param>
-               public MySqlConnection(string connectString)
-               {
-                       settings = new MySqlConnectionString(connectString);
-               }
-
-               /// <summary>
-               /// Gets the name of the MySQL server to which to connect.
-               /// </summary>
-               #region Properties
-               [Browsable(true)]
-               public string DataSource
-               {
-                       get { return settings.Host; }
-               }
-
-               /// <summary>
-               /// Gets the time to wait while trying to establish a connection before terminating the attempt and generating an error.
-               /// </summary>
-               /// <include file='docs/MySqlConnection.xml' path='MyDocs/MyMembers[@name="ConnectionTimeout"]/*'/>
-               [Browsable(true)]
-               public int ConnectionTimeout
-               {
-                       get { return settings.ConnectTimeout; }
-               }
-               
-               /// <summary>
-               /// Gets the name of the current database or the database to be used after a connection is opened.
-               /// </summary>
-               [Browsable(true)]
-               public string Database
-               {
-                       get     { return settings.Database; }
-               }
-
-               /// <summary>
-               /// Indicates if this connection should use compression when communicating with the server.
-               /// </summary>
-               [Browsable(false)]
-               public bool UseCompression
-               {
-                       get { return settings.UseCompression; }
-               }
-               
-               /// <summary>
-               /// Gets the current state of the connection.
-               /// </summary>
-               [Browsable(false)]
-               public ConnectionState State
-               {
-                       get { return state; }
-               }
-
-               internal MySqlDataReader Reader
-               {
-                       get { return dataReader; }
-                       set { dataReader = value; }
-               }
-
-               internal MySqlInternalConnection InternalConnection
-               {
-                       get { return internalConnection; }
-               }
-
-               internal NumberFormatInfo NumberFormat
-               {
-                       get 
-                       {
-                               if (numberFormat == null)
-                               {
-                                       numberFormat = new NumberFormatInfo();
-                                       numberFormat = (NumberFormatInfo)NumberFormatInfo.InvariantInfo.Clone();
-                                       numberFormat.NumberDecimalSeparator = ".";
-                               }
-                               return numberFormat;
-                       }
-               }
-
-               /// <summary>
-               /// Gets a string containing the version of the MySQL server to which the client is connected.
-               /// </summary>
-               [Browsable(false)]
-               public string ServerVersion 
-               {
-                       get { return  internalConnection.Driver.Version; }
-               }
-
-               internal Encoding Encoding 
-               {
-                       get 
-                       {
-                               if (internalConnection == null)
-                                       return System.Text.Encoding.Default;
-                               else 
-                                       return internalConnection.Driver.Encoding;
-                       }
-               }
-
-
-               /// <summary>
-               /// Gets or sets the string used to connect to a MySQL Server database.
-               /// </summary>
-               /// <include file='docs/MySqlConnection.xml' path='MyDocs/MyMembers[@name="ConnectionString"]/*'/>
-#if WINDOWS
-               [Editor(typeof(Designers.ConnectionStringEditor), typeof(System.Drawing.Design.UITypeEditor))]
-#endif
-               [Browsable(true)]
-               [Category("Data")]
-               public string ConnectionString
-               {
-                       get
-                       {
-                               // Always return exactly what the user set.
-                               // Security-sensitive information may be removed.
-                               return settings.ConnectString;
-                       }
-                       set
-                       {
-                               settings.ConnectString = value;
-                               if (internalConnection != null)
-                                       internalConnection.Settings = settings;
-                       }
-               }
-
-               #endregion
-
-               #region Transactions
-               /// <summary>
-               /// Begins a database transaction.
-               /// </summary>
-               /// <returns></returns>
-               public MySqlTransaction BeginTransaction()
-               {
-                       if (state != ConnectionState.Open)
-                               throw new MySqlException("Invalid operation: The connection is closed");
-
-                       MySqlTransaction t = new MySqlTransaction();
-                       t.Connection = this;
-                       InternalConnection.Driver.SendCommand( DBCmd.QUERY, "BEGIN");
-                       return t;
-               }
-
-               /// <summary>
-               /// 
-               /// </summary>
-               IDbTransaction IDbConnection.BeginTransaction()
-               {
-                       return BeginTransaction();
-               }
-
-               /// <summary>
-               /// 
-               /// </summary>
-               /// <param name="level"></param>
-               /// <returns></returns>
-               public MySqlTransaction BeginTransaction(IsolationLevel level)
-               {
-                       if (state != ConnectionState.Open)
-                               throw new MySqlException("Invalid operation: The connection is closed");
-
-                       MySqlTransaction t = new MySqlTransaction();
-                       t.Connection = this;
-                       t.IsolationLevel = level;
-                       string cmd = "SET SESSION TRANSACTION ISOLATION LEVEL ";
-                       switch (level) 
-                       {
-                               case IsolationLevel.ReadCommitted:
-                                       cmd += "READ COMMITTED"; break;
-                               case IsolationLevel.ReadUncommitted:
-                                       cmd += "READ UNCOMMITTED"; break;
-                               case IsolationLevel.RepeatableRead:
-                                       cmd += "REPEATABLE READ"; break;
-                               case IsolationLevel.Serializable:
-                                       cmd += "SERIALIZABLE"; break;
-                               case IsolationLevel.Chaos:
-                                       throw new NotSupportedException("Chaos isolation level is not supported");
-                       }
-                       InternalConnection.Driver.SendCommand( DBCmd.QUERY, cmd );
-                       InternalConnection.Driver.SendCommand( DBCmd.QUERY, "BEGIN");
-                       return t;
-               }
-
-               /// <summary>
-               /// 
-               /// </summary>
-               /// <param name="level"></param>
-               /// <returns></returns>
-               IDbTransaction IDbConnection.BeginTransaction(IsolationLevel level)
-               {
-                       return BeginTransaction(level);
-               }
-               #endregion
-
-               /// <summary>
-               /// Changes the current database for an open MySqlConnection.
-               /// </summary>
-               /// <param name="dbName"></param>
-               public void ChangeDatabase(string dbName)
-               {
-                       if (state != ConnectionState.Open)
-                               throw new MySqlException("Invalid operation: The connection is closed");
-
-                       //TODOinternalConnection.ChangeDatabase( dbName );
-                       InternalConnection.Driver.SendCommand( DBCmd.INIT_DB, dbName );
-               }
-
-               internal void SetState( ConnectionState newState ) 
-               {
-                       ConnectionState oldState = state;
-                       state = newState;
-                       if (this.StateChange != null)
-                               StateChange(this, new StateChangeEventArgs( oldState, newState ));
-               }
-
-               /// <summary>
-               /// Opens a database connection with the property settings specified by the ConnectionString.
-               /// </summary>
-               public void Open()
-               {
-                       if (state == ConnectionState.Open)
-                               throw new MySqlException("error connecting: The connection is already Open (state=Open).");
-
-                       SetState( ConnectionState.Connecting );
-
-                       if (settings.Pooling) 
-                       {
-                               internalConnection = MySqlPoolManager.GetConnection( settings );
-                       }
-                       else
-                       {
-                               internalConnection = new MySqlInternalConnection( settings );
-                               internalConnection.Open();
-                       }
-
-                       SetState( ConnectionState.Open );
-                       internalConnection.SetServerVariables(this);
-                       ChangeDatabase( settings.Database );
-               }
-
-
-               /// <summary>
-               /// Closes the connection to the database. This is the preferred method of closing any open connection.
-               /// </summary>
-               public void Close()
-               {
-                       if (state == ConnectionState.Closed) return;
-
-                       if (dataReader != null)
-                               dataReader.Close();
-
-                       if (settings.Pooling)
-                               MySqlPoolManager.ReleaseConnection( internalConnection );
-                       else
-                               internalConnection.Close();
-
-                       SetState( ConnectionState.Closed );
-               }
-
-               IDbCommand IDbConnection.CreateCommand()
-               {
-                       return CreateCommand();
-               }
-
-               /// <summary>
-               /// Creates and returns a MySqlCommand object associated with the MySqlConnection.
-               /// </summary>
-               /// <returns></returns>
-               public MySqlCommand CreateCommand()
-               {
-                       // Return a new instance of a command object.
-                       MySqlCommand c = new MySqlCommand();
-                       c.Connection = this;
-                       return c;
-               }
-
-               #region ICloneable
-               /// <summary>
-               /// Creates a new MySqlConnection object with the exact same ConnectionString value
-               /// </summary>
-               /// <returns>A cloned MySqlConnection object</returns>
-               object ICloneable.Clone()
-               {
-                       MySqlConnection clone = new MySqlConnection();
-                       clone.ConnectionString = this.ConnectionString;
-                       //TODO:  how deep should this go?
-                       return clone;
-               }
-               #endregion
-
-               #region IDisposeable
-               /// <summary>
-               /// Releases the resources used by the MySqlConnection.
-               /// </summary>
-               public new void Dispose() 
-               {
-                       if (State == ConnectionState.Open)
-                               Close();
-                       base.Dispose();
-               }
-               #endregion
-  }
-}
+// ByteFX.Data data access components for .Net\r
+// Copyright (C) 2002-2003  ByteFX, Inc.\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License, or (at your option) any later version.\r
+// \r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+// Lesser General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+\r
+using System;\r
+using System.Data;\r
+using System.Collections.Specialized;\r
+using System.Text;\r
+using System.ComponentModel;\r
+using System.Globalization;\r
+using ByteFX.Data.Common;\r
+\r
+namespace ByteFX.Data.MySqlClient\r
+{\r
+       /// <summary>\r
+       /// Represents an open connection to a MySQL Server database. This class cannot be inherited.\r
+       /// </summary>\r
+       /// <include file='docs/MySqlConnection.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>\r
+       [System.Drawing.ToolboxBitmap( typeof(MySqlConnection), "MySqlClient.resources.connection.bmp")]\r
+       [System.ComponentModel.DesignerCategory("Code")]\r
+       [ToolboxItem(true)]\r
+       public sealed class MySqlConnection : Component, IDbConnection, ICloneable\r
+       {\r
+               internal ConnectionState                        state;\r
+               private  MySqlInternalConnection        internalConnection;\r
+               private  MySqlDataReader                        dataReader;\r
+               private  NumberFormatInfo                       numberFormat;\r
+               private  MySqlConnectionString          settings;\r
+\r
+               /// <summary>\r
+               /// Occurs when the state of the connection changes.\r
+               /// </summary>\r
+               public event StateChangeEventHandler    StateChange;\r
+\r
+\r
+               /// <summary>\r
+               /// Creates a new connection\r
+               /// </summary>\r
+               public MySqlConnection()\r
+               {\r
+                       settings = new MySqlConnectionString("server=localhost");\r
+               }\r
+\r
+               /// <summary>\r
+               /// Creates a new connection\r
+               /// </summary>\r
+               /// <param name="container"></param>\r
+               public MySqlConnection(System.ComponentModel.IContainer container)\r
+               {\r
+                       settings = new MySqlConnectionString();\r
+               }\r
+    \r
+\r
+               // Have a constructor that takes a connection string.\r
+               /// <summary>\r
+               /// Creates a new connection using the specified connection string.\r
+               /// </summary>\r
+               /// <param name="connectString"></param>\r
+               public MySqlConnection(string connectString)\r
+               {\r
+                       settings = new MySqlConnectionString(connectString);\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the name of the MySQL server to which to connect.\r
+               /// </summary>\r
+               #region Properties\r
+               [Browsable(true)]\r
+               public string DataSource\r
+               {\r
+                       get { return settings.Server; }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the time to wait while trying to establish a connection before terminating the attempt and generating an error.\r
+               /// </summary>\r
+               /// <include file='docs/MySqlConnection.xml' path='MyDocs/MyMembers[@name="ConnectionTimeout"]/*'/>\r
+               [Browsable(true)]\r
+               public int ConnectionTimeout\r
+               {\r
+                       get { return settings.ConnectionTimeout; }\r
+               }\r
+               \r
+               /// <summary>\r
+               /// Gets the name of the current database or the database to be used after a connection is opened.\r
+               /// </summary>\r
+               [Browsable(true)]\r
+               public string Database\r
+               {\r
+                       get     { return settings.Database; }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Indicates if this connection should use compression when communicating with the server.\r
+               /// </summary>\r
+               [Browsable(false)]\r
+               public bool UseCompression\r
+               {\r
+                       get { return settings.UseCompression; }\r
+               }\r
+               \r
+               /// <summary>\r
+               /// Gets the current state of the connection.\r
+               /// </summary>\r
+               [Browsable(false)]\r
+               public ConnectionState State\r
+               {\r
+                       get { return state; }\r
+               }\r
+\r
+               internal MySqlDataReader Reader\r
+               {\r
+                       get { return dataReader; }\r
+                       set { dataReader = value; }\r
+               }\r
+\r
+               internal MySqlInternalConnection InternalConnection\r
+               {\r
+                       get { return internalConnection; }\r
+               }\r
+\r
+               internal NumberFormatInfo NumberFormat\r
+               {\r
+                       get \r
+                       {\r
+                               if (numberFormat == null)\r
+                               {\r
+                                       numberFormat = new NumberFormatInfo();\r
+                                       numberFormat = (NumberFormatInfo)NumberFormatInfo.InvariantInfo.Clone();\r
+                                       numberFormat.NumberDecimalSeparator = ".";\r
+                               }\r
+                               return numberFormat;\r
+                       }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets a string containing the version of the MySQL server to which the client is connected.\r
+               /// </summary>\r
+               [Browsable(false)]\r
+               public string ServerVersion \r
+               {\r
+                       get { return  internalConnection.Driver.VersionString; }\r
+               }\r
+\r
+               internal Encoding Encoding \r
+               {\r
+                       get \r
+                       {\r
+                               if (internalConnection == null)\r
+                                       return System.Text.Encoding.Default;\r
+                               else \r
+                                       return internalConnection.Driver.Encoding;\r
+                       }\r
+               }\r
+\r
+\r
+               /// <summary>\r
+               /// Gets or sets the string used to connect to a MySQL Server database.\r
+               /// </summary>\r
+               /// <include file='docs/MySqlConnection.xml' path='MyDocs/MyMembers[@name="ConnectionString"]/*'/>\r
+#if WINDOWS\r
+               [Editor("ByteFX.Data.MySqlClient.Design.ConnectionStringTypeEditor,MySqlClient.Design", typeof(System.Drawing.Design.UITypeEditor))]\r
+#endif\r
+               [Browsable(true)]\r
+               [Category("Data")]\r
+               [Description("Information used to connect to a DataSource, such as 'Server=xxx;UserId=yyy;Password=zzz;Database=dbdb'.")]\r
+               public string ConnectionString\r
+               {\r
+                       get\r
+                       {\r
+                               // Always return exactly what the user set.\r
+                               // Security-sensitive information may be removed.\r
+                               return settings.GetConnectionString();\r
+                       }\r
+                       set\r
+                       {\r
+                               if (this.State != ConnectionState.Closed)\r
+                                       throw new MySqlException("Not allowed to change the 'ConnectionString' property while the connection (state=" + State + ").");\r
+\r
+                               settings.SetConnectionString(value);\r
+                               if (internalConnection != null)\r
+                                       internalConnection.Settings = settings;\r
+                       }\r
+               }\r
+\r
+               #endregion\r
+\r
+               #region Transactions\r
+               /// <summary>\r
+               /// Begins a database transaction.\r
+               /// </summary>\r
+               /// <returns></returns>\r
+               public MySqlTransaction BeginTransaction()\r
+               {\r
+                       if (state != ConnectionState.Open)\r
+                               throw new MySqlException("Invalid operation: The connection is closed");\r
+\r
+                       MySqlTransaction t = new MySqlTransaction();\r
+                       t.Connection = this;\r
+                       InternalConnection.Driver.Send( DBCmd.QUERY, "BEGIN");\r
+                       return t;\r
+               }\r
+\r
+               /// <summary>\r
+               /// \r
+               /// </summary>\r
+               IDbTransaction IDbConnection.BeginTransaction()\r
+               {\r
+                       return BeginTransaction();\r
+               }\r
+\r
+               /// <summary>\r
+               /// \r
+               /// </summary>\r
+               /// <param name="level"></param>\r
+               /// <returns></returns>\r
+               public MySqlTransaction BeginTransaction(IsolationLevel level)\r
+               {\r
+                       if (state != ConnectionState.Open)\r
+                               throw new MySqlException("Invalid operation: The connection is closed");\r
+\r
+                       MySqlTransaction t = new MySqlTransaction();\r
+                       t.Connection = this;\r
+                       t.IsolationLevel = level;\r
+                       string cmd = "SET SESSION TRANSACTION ISOLATION LEVEL ";\r
+                       switch (level) \r
+                       {\r
+                               case IsolationLevel.ReadCommitted:\r
+                                       cmd += "READ COMMITTED"; break;\r
+                               case IsolationLevel.ReadUncommitted:\r
+                                       cmd += "READ UNCOMMITTED"; break;\r
+                               case IsolationLevel.RepeatableRead:\r
+                                       cmd += "REPEATABLE READ"; break;\r
+                               case IsolationLevel.Serializable:\r
+                                       cmd += "SERIALIZABLE"; break;\r
+                               case IsolationLevel.Chaos:\r
+                                       throw new NotSupportedException("Chaos isolation level is not supported");\r
+                       }\r
+                       InternalConnection.Driver.Send( DBCmd.QUERY, cmd );\r
+                       InternalConnection.Driver.Send( DBCmd.QUERY, "BEGIN");\r
+                       return t;\r
+               }\r
+\r
+               /// <summary>\r
+               /// \r
+               /// </summary>\r
+               /// <param name="level"></param>\r
+               /// <returns></returns>\r
+               IDbTransaction IDbConnection.BeginTransaction(IsolationLevel level)\r
+               {\r
+                       return BeginTransaction(level);\r
+               }\r
+               #endregion\r
+\r
+               /// <summary>\r
+               /// Changes the current database for an open MySqlConnection.\r
+               /// </summary>\r
+               /// <param name="dbName"></param>\r
+               public void ChangeDatabase(string dbName)\r
+               {\r
+                       if (state != ConnectionState.Open)\r
+                               throw new MySqlException("Invalid operation: The connection is closed");\r
+\r
+                       //TODOinternalConnection.ChangeDatabase( dbName );\r
+                       InternalConnection.Driver.Send( DBCmd.INIT_DB, dbName );\r
+               }\r
+\r
+               internal void SetState( ConnectionState newState ) \r
+               {\r
+                       ConnectionState oldState = state;\r
+                       state = newState;\r
+                       if (this.StateChange != null)\r
+                               StateChange(this, new StateChangeEventArgs( oldState, newState ));\r
+               }\r
+\r
+               /// <summary>\r
+               /// Opens a database connection with the property settings specified by the ConnectionString.\r
+               /// </summary>\r
+               public void Open()\r
+               {\r
+                       if (state == ConnectionState.Open)\r
+                               throw new MySqlException("error connecting: The connection is already Open (state=Open).");\r
+\r
+                       SetState( ConnectionState.Connecting );\r
+\r
+                       try \r
+                       {\r
+                               if (settings.Pooling) \r
+                               {\r
+                                       internalConnection = MySqlPoolManager.GetConnection( settings );\r
+                               }\r
+                               else\r
+                               {\r
+                                       internalConnection = new MySqlInternalConnection( settings );\r
+                                       internalConnection.Open();\r
+                               }\r
+                       }\r
+                       catch (Exception ex)\r
+                       {\r
+                               SetState( ConnectionState.Closed );\r
+                               throw ex;\r
+                       }\r
+\r
+\r
+                       SetState( ConnectionState.Open );\r
+                       internalConnection.SetServerVariables(this);\r
+                       if (settings.Database != null && settings.Database != String.Empty)\r
+                               ChangeDatabase( settings.Database );\r
+               }\r
+\r
+\r
+               /// <summary>\r
+               /// Closes the connection to the database. This is the preferred method of closing any open connection.\r
+               /// </summary>\r
+               public void Close()\r
+               {\r
+                       if (state == ConnectionState.Closed) return;\r
+\r
+                       if (dataReader != null)\r
+                               dataReader.Close();\r
+\r
+                       if (settings.Pooling)\r
+                               MySqlPoolManager.ReleaseConnection( internalConnection );\r
+                       else\r
+                               internalConnection.Close();\r
+\r
+                       SetState( ConnectionState.Closed );\r
+               }\r
+\r
+               IDbCommand IDbConnection.CreateCommand()\r
+               {\r
+                       return CreateCommand();\r
+               }\r
+\r
+               /// <summary>\r
+               /// Creates and returns a MySqlCommand object associated with the MySqlConnection.\r
+               /// </summary>\r
+               /// <returns></returns>\r
+               public MySqlCommand CreateCommand()\r
+               {\r
+                       // Return a new instance of a command object.\r
+                       MySqlCommand c = new MySqlCommand();\r
+                       c.Connection = this;\r
+                       return c;\r
+               }\r
+\r
+               #region ICloneable\r
+               /// <summary>\r
+               /// Creates a new MySqlConnection object with the exact same ConnectionString value\r
+               /// </summary>\r
+               /// <returns>A cloned MySqlConnection object</returns>\r
+               object ICloneable.Clone()\r
+               {\r
+                       MySqlConnection clone = new MySqlConnection();\r
+                       clone.ConnectionString = this.ConnectionString;\r
+                       //TODO:  how deep should this go?\r
+                       return clone;\r
+               }\r
+               #endregion\r
+\r
+               #region IDisposeable\r
+               /// <summary>\r
+               /// Releases the resources used by the MySqlConnection.\r
+               /// </summary>\r
+               public new void Dispose() \r
+               {\r
+                       if (State == ConnectionState.Open)\r
+                               Close();\r
+                       base.Dispose();\r
+               }\r
+               #endregion\r
+  }\r
+}\r
index 7e323966c18c06ea7fd44df07b63102db352eb20..6b3c4ce0a5ffa619d583a9ec4b09b49c9ee23c37 100755 (executable)
@@ -1,42 +1,42 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<root>
-       <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
-               <xsd:element name="root" msdata:IsDataSet="true">
-                       <xsd:complexType>
-                               <xsd:choice maxOccurs="unbounded">
-                                       <xsd:element name="data">
-                                               <xsd:complexType>
-                                                       <xsd:sequence>
-                                                               <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
-                                                               <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
-                                                       </xsd:sequence>
-                                                       <xsd:attribute name="name" type="xsd:string" />
-                                                       <xsd:attribute name="type" type="xsd:string" />
-                                                       <xsd:attribute name="mimetype" type="xsd:string" />
-                                               </xsd:complexType>
-                                       </xsd:element>
-                                       <xsd:element name="resheader">
-                                               <xsd:complexType>
-                                                       <xsd:sequence>
-                                                               <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
-                                                       </xsd:sequence>
-                                                       <xsd:attribute name="name" type="xsd:string" use="required" />
-                                               </xsd:complexType>
-                                       </xsd:element>
-                               </xsd:choice>
-                       </xsd:complexType>
-               </xsd:element>
-       </xsd:schema>
-       <resheader name="ResMimeType">
-               <value>text/microsoft-resx</value>
-       </resheader>
-       <resheader name="Version">
-               <value>1.0.0.0</value>
-       </resheader>
-       <resheader name="Reader">
-               <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
-       </resheader>
-       <resheader name="Writer">
-               <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
-       </resheader>
-</root>
+<?xml version="1.0" encoding="utf-8" ?>\r
+<root>\r
+       <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">\r
+               <xsd:element name="root" msdata:IsDataSet="true">\r
+                       <xsd:complexType>\r
+                               <xsd:choice maxOccurs="unbounded">\r
+                                       <xsd:element name="data">\r
+                                               <xsd:complexType>\r
+                                                       <xsd:sequence>\r
+                                                               <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+                                                               <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />\r
+                                                       </xsd:sequence>\r
+                                                       <xsd:attribute name="name" type="xsd:string" />\r
+                                                       <xsd:attribute name="type" type="xsd:string" />\r
+                                                       <xsd:attribute name="mimetype" type="xsd:string" />\r
+                                               </xsd:complexType>\r
+                                       </xsd:element>\r
+                                       <xsd:element name="resheader">\r
+                                               <xsd:complexType>\r
+                                                       <xsd:sequence>\r
+                                                               <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+                                                       </xsd:sequence>\r
+                                                       <xsd:attribute name="name" type="xsd:string" use="required" />\r
+                                               </xsd:complexType>\r
+                                       </xsd:element>\r
+                               </xsd:choice>\r
+                       </xsd:complexType>\r
+               </xsd:element>\r
+       </xsd:schema>\r
+       <resheader name="ResMimeType">\r
+               <value>text/microsoft-resx</value>\r
+       </resheader>\r
+       <resheader name="Version">\r
+               <value>1.0.0.0</value>\r
+       </resheader>\r
+       <resheader name="Reader">\r
+               <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+       </resheader>\r
+       <resheader name="Writer">\r
+               <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+       </resheader>\r
+</root>\r
index 1fc4328b9f6c6616092786396574eb9bafdd1b08..b90728a119c0e30bdec0f45f6ecf719d28b1a110 100644 (file)
-using System;
-using ByteFX.Data.Common;
-
-namespace ByteFX.Data.MySqlClient
-{
-       /// <summary>
-       /// 
-       /// </summary>
-       internal sealed class MySqlInternalConnection
-       {
-               MySqlConnectionString   settings;
-               Driver                                  driver;
-               DateTime                                createTime;
-               bool                                    serverVariablesSet;
-
-               public MySqlInternalConnection( MySqlConnectionString connectString )
-               {
-                       settings = connectString;
-                       serverVariablesSet = false;
-               }
-
-               #region Properties
-               public MySqlConnectionString Settings 
-               {
-                       get { return settings; }
-                       set { settings = value; }
-               }
-
-               internal Driver Driver 
-               {
-                       get { return driver; }
-               }
-
-               #endregion
-
-               #region Methods
-
-               public bool IsAlive() 
-               {
-                       Packet packet;
-                       try 
-                       {
-                               byte[] bytes = driver.Encoding.GetBytes("select connection_id();");
-                               packet = driver.SendSql( bytes );
-                               // we have to read for two last packets since MySql sends
-                               // us a last packet after schema and again after rows
-                               // I will likely change this later to have the driver just
-                               // return schema in one very large packet.
-                               while (! packet.IsLastPacket())
-                                       packet = driver.ReadPacket();
-
-                               // now read off the resultset
-                               packet = driver.ReadPacket();
-                               while (! packet.IsLastPacket())
-                                       packet = driver.ReadPacket();
-                               return true;
-                       }
-                       catch (Exception ex)
-                       {
-                               return false;
-                       }
-               }
-
-               public bool IsTooOld() 
-               {
-                       TimeSpan ts = DateTime.Now.Subtract( createTime );
-                       if (ts.Seconds > settings.ConnectionLifetime)
-                               return true;
-                       return false;
-               }
-
-               /// <summary>
-               /// I don't like this setup but can't think of a better way of doing
-               /// right now.
-               /// </summary>
-               /// <param name="connection"></param>
-               public void SetServerVariables(MySqlConnection connection)
-               {
-                       if (serverVariablesSet) return;
-
-                       // retrieve the encoding that should be used for character data
-                       MySqlCommand cmd = new MySqlCommand("show variables like 'max_allowed_packet'", connection);
-                       try 
-                       {
-                               MySqlDataReader reader = cmd.ExecuteReader();
-                               reader.Read();
-                               driver.MaxPacketSize = reader.GetInt64( 1 );
-                               reader.Close();
-                       }
-                       catch 
-                       {
-                               driver.MaxPacketSize = 1047552;
-                       }
-
-                       cmd.CommandText = "show variables like 'character_set'";
-                       driver.Encoding = System.Text.Encoding.Default;
-                       
-                       try 
-                       {
-                               MySqlDataReader reader = cmd.ExecuteReader();
-                               if (reader.Read())
-                                       driver.Encoding = CharSetMap.GetEncoding( reader.GetString(1) );
-                               reader.Close();
-                       }
-                       catch 
-                       { 
-                               throw new MySqlException("Failure to initialize connection");
-                       }
-
-                       serverVariablesSet = true;
-               }
-
-               public void Open() 
-               {
-                       driver = new Driver();
-                       driver.Open( settings );
-
-                       createTime = DateTime.Now;
-               }
-
-               public void Close() 
-               {
-                       driver.Close();
-               }
-
-               #endregion
-
-       }
-}
+using System;\r
+using ByteFX.Data.Common;\r
+\r
+namespace ByteFX.Data.MySqlClient\r
+{\r
+       /// <summary>\r
+       /// \r
+       /// </summary>\r
+       internal sealed class MySqlInternalConnection\r
+       {\r
+               MySqlConnectionString   settings;\r
+               Driver                                  driver;\r
+               DateTime                                createTime;\r
+               bool                                    serverVariablesSet;\r
+\r
+               public MySqlInternalConnection( MySqlConnectionString connectString )\r
+               {\r
+                       settings = connectString;\r
+                       serverVariablesSet = false;\r
+               }\r
+\r
+               #region Properties\r
+               public MySqlConnectionString Settings \r
+               {\r
+                       get { return settings; }\r
+                       set { settings = value; }\r
+               }\r
+\r
+               internal Driver Driver \r
+               {\r
+                       get { return driver; }\r
+               }\r
+\r
+               #endregion\r
+\r
+               #region Methods\r
+\r
+               public bool IsAlive() \r
+               {\r
+                       try \r
+                       {\r
+                               CommandResult result = driver.Send( DBCmd.PING, (byte[])null );\r
+                               // we don't care about the result.  The fact that it responded is enough\r
+                               return true;\r
+                       }\r
+                       catch (Exception)\r
+                       {\r
+                               return false;\r
+                       }\r
+               }\r
+\r
+               public bool IsTooOld() \r
+               {\r
+                       TimeSpan ts = DateTime.Now.Subtract( createTime );\r
+                       if (ts.Seconds > settings.ConnectionLifetime)\r
+                               return true;\r
+                       return false;\r
+               }\r
+\r
+               /// <summary>\r
+               /// I don't like this setup but can't think of a better way of doing\r
+               /// right now.\r
+               /// </summary>\r
+               /// <param name="connection"></param>\r
+               public void SetServerVariables(MySqlConnection connection)\r
+               {\r
+                       if (serverVariablesSet) return;\r
+\r
+                       // retrieve the encoding that should be used for character data\r
+                       MySqlCommand cmd = new MySqlCommand("show variables like 'max_allowed_packet'", connection);\r
+                       try \r
+                       {\r
+                               MySqlDataReader reader = cmd.ExecuteReader();\r
+                               reader.Read();\r
+                               driver.MaxPacketSize = reader.GetInt64( 1 );\r
+                               reader.Close();\r
+                       }\r
+                       catch (Exception)\r
+                       {\r
+                               driver.MaxPacketSize = 1047552;\r
+                       }\r
+\r
+                       cmd.CommandText = "show variables like 'character_set'";\r
+                       driver.Encoding = System.Text.Encoding.Default;\r
+               \r
+                       try \r
+                       {\r
+                               MySqlDataReader reader = cmd.ExecuteReader();\r
+                               if (reader.Read())\r
+                                       driver.Encoding = CharSetMap.GetEncoding( reader.GetString(1) );\r
+                               reader.Close();\r
+                       }\r
+                       catch \r
+                       { \r
+                               throw new MySqlException("Failure to initialize connection");\r
+                       }\r
+\r
+                       serverVariablesSet = true;\r
+               }\r
+\r
+               public void Open() \r
+               {\r
+                       driver = new Driver();\r
+                       driver.Open( settings );\r
+\r
+                       createTime = DateTime.Now;\r
+               }\r
+\r
+               public void Close() \r
+               {\r
+                       driver.Close();\r
+               }\r
+\r
+               #endregion\r
+\r
+       }\r
+}\r
index f3a9567d794835455253aecba0018a2bdcafa9ab..b32972510a53efe3c830dd19d0015493f3de1e97 100644 (file)
-using System;
-using ByteFX.Data.Common;
-
-namespace ByteFX.Data.MySqlClient
-{
-       /// <summary>
-       /// Summary description for MySqlConnectionString.
-       /// </summary>
-       internal sealed class MySqlConnectionString : DBConnectionString
-       {
-               private bool useCompression = false;
-
-               public MySqlConnectionString() 
-               {
-                       connectLifetime = 0;
-                       pooling = true;
-                       minPoolSize = 0;
-                       maxPoolSize = 100;
-                       connectTimeout = 15;
-                       port = 3306;
-               }
-
-               public MySqlConnectionString(string connectString) : base(connectString)
-               {
-                       connectLifetime = 0;
-                       pooling = true;
-                       minPoolSize = 0;
-                       maxPoolSize = 100;
-                       connectTimeout = 15;
-                       port = 3306;
-                       Parse();
-               }
-
-               #region Properties
-               public bool UseCompression 
-               {
-                       get { return useCompression; }
-               }
-               #endregion
-
-               protected override void ConnectionParameterParsed(string key, string value)
-               {
-                       switch (key.ToLower()) 
-                       {
-                               case "use compression":
-                               case "compress":
-                                       if (value.ToLower() == "no" || value.ToLower() == "false")
-                                               useCompression = false;
-                                       else
-                                               useCompression = true;
-                                       break;
-                       }
-
-                       base.ConnectionParameterParsed(key, value);
-               }
-
-       }
-}
+using System;\r
+using System.Collections;\r
+using System.ComponentModel;\r
+using System.Text;\r
+using ByteFX.Data.Common;\r
+\r
+namespace ByteFX.Data.MySqlClient\r
+{\r
+       internal enum ConnectionProtocol \r
+       {\r
+               Sockets, NamedPipe, UnixSocket\r
+       }\r
+\r
+       /// <summary>\r
+       /// Summary description for MySqlConnectionString.\r
+       /// </summary>\r
+       internal sealed class MySqlConnectionString : DBConnectionString\r
+       {\r
+               private Hashtable       defaults;\r
+\r
+               public MySqlConnectionString() : base()\r
+               {\r
+               }\r
+\r
+               public MySqlConnectionString(string connectString) : this()\r
+               {\r
+                       SetConnectionString( connectString );\r
+               }\r
+\r
+               #region Server Properties\r
+               [Browsable(false)]\r
+               public string Name \r
+               {\r
+                       get { return connectionName; }\r
+                       set { connectionName = value; }\r
+               }\r
+\r
+\r
+               [Category("Connection")]\r
+               [Description("The name or IP address of the server to use")]\r
+               public string Server \r
+               {\r
+                       get { return GetString("host"); }\r
+                       set { keyValues["host"] = value; }\r
+               }\r
+\r
+               [Category("Connection")]\r
+               [Description("Port to use when connecting with sockets")]\r
+               [DefaultValue(3306)]\r
+               public int Port \r
+               {\r
+                       get { return GetInt("port"); }\r
+                       set { keyValues["port"] = value; }\r
+               }\r
+\r
+               [Category("Connection")]\r
+               [Description("Protocol to use for connection to MySQL")]\r
+               [DefaultValue(ConnectionProtocol.Sockets)]\r
+               public ConnectionProtocol Protocol\r
+               {\r
+                       get { return (ConnectionProtocol)keyValues["protocol"]; }\r
+                       set { keyValues["protocol"] = value; }\r
+               }\r
+\r
+               [Category("Connection")]\r
+               [Description("Name of pipe to use when connecting with named pipes (Win32 only)")]\r
+               public string PipeName \r
+               {\r
+                       get { return GetString("use pipe"); }\r
+                       set { keyValues["use pipe"] = value; }\r
+               }\r
+\r
+               [Category("Connection")]\r
+               [Description("Should the connection ues compression")]\r
+               [DefaultValue(false)]\r
+               public bool UseCompression \r
+               {\r
+                       get { return GetBool("compress"); }\r
+                       set { keyValues["compress"] = value; }\r
+               }\r
+\r
+               [Category("Connection")]\r
+               [Description("Database to use initially")]\r
+               [Editor("ByteFX.Data.MySqlClient.Design.DatabaseTypeEditor,MySqlClient.Design", typeof(System.Drawing.Design.UITypeEditor))]\r
+               public string Database\r
+               {\r
+                       get { return GetString("database"); }\r
+                       set { keyValues["database"] = value; }\r
+               }\r
+\r
+               [Category("Connection")]\r
+               [Description("Number of seconds to wait for the connection to succeed")]\r
+               [DefaultValue(15)]\r
+               public int ConnectionTimeout\r
+               {\r
+                       get { return GetInt("connect timeout"); }\r
+                       set { keyValues["connect timeout"] = value; }\r
+               }\r
+               #endregion\r
+\r
+               #region Authentication Properties\r
+\r
+               [Category("Authentication")]\r
+               [Description("The username to connect as")]\r
+               public string UserId \r
+               {\r
+                       get { return GetString("user id"); }\r
+                       set { keyValues["user id"] = value; }\r
+               }\r
+\r
+               [Category("Authentication")]\r
+               [Description("The password to use for authentication")]\r
+               public string Password \r
+               {\r
+                       get { return GetString("password"); }\r
+                       set { keyValues["password"] = value; }\r
+               }\r
+\r
+               [Category("Authentication")]\r
+               [Description("Should the connection use SSL.  This currently has no effect.")]\r
+               [DefaultValue(false)]\r
+               public bool UseSSL\r
+               {\r
+                       get { return GetBool("use ssl"); }\r
+                       set { keyValues["use ssl"] = value; }\r
+               }\r
+\r
+               [Category("Authentication")]\r
+               [Description("Show user password in connection string")]\r
+               [DefaultValue(false)]\r
+               public bool PersistSecurityInfo \r
+               {\r
+                       get { return GetBool("persist security info"); }\r
+                       set { keyValues["persist security info"] = value; }\r
+               }\r
+               #endregion\r
+\r
+               #region Pooling Properties\r
+\r
+               [Category("Pooling")]\r
+               [Description("Should the connection support pooling")]\r
+               [DefaultValue(true)]\r
+               public bool Pooling \r
+               {\r
+                       get { return GetBool("pooling"); }\r
+                       set { keyValues["pooling"] = value; }\r
+               }\r
+\r
+               [Category("Pooling")]\r
+               [Description("Minimum number of connections to have in this pool")]\r
+               [DefaultValue(0)]\r
+               public int MinPoolSize \r
+               {\r
+                       get { return GetInt("min pool size"); }\r
+                       set { keyValues["min pool size"] = value; }\r
+               }\r
+\r
+               [Category("Pooling")]\r
+               [Description("Maximum number of connections to have in this pool")]\r
+               [DefaultValue(100)]\r
+               public int MaxPoolSize \r
+               {\r
+                       get { return GetInt("max pool size"); }\r
+                       set { keyValues["max pool size"] = value; }\r
+               }\r
+\r
+               [Category("Pooling")]\r
+               [Description("Maximum number of seconds a connection should live.  This is checked when a connection is returned to the pool.")]\r
+               [DefaultValue(0)]\r
+               public int ConnectionLifetime \r
+               {\r
+                       get { return GetInt("connection lifetime"); }\r
+                       set { keyValues["connection lifetime"] = value; }\r
+               }\r
+\r
+               #endregion\r
+\r
+\r
+               /// <summary>\r
+               /// Takes a given connection string and returns it, possible\r
+               /// stripping out the password info\r
+               /// </summary>\r
+               /// <returns></returns>\r
+               public string GetConnectionString()\r
+               {\r
+                       if (connectString == null) return CreateConnectionString();\r
+\r
+                       StringBuilder str = new StringBuilder();\r
+                       Hashtable ht = ParseKeyValuePairs( connectString );\r
+\r
+                       if (! PersistSecurityInfo) \r
+                               ht.Remove("password");\r
+\r
+                       foreach( string key in ht.Keys)\r
+                               str.AppendFormat("{0}={1};", key, ht[key]);\r
+\r
+                       if (str.Length > 0)\r
+                               str.Remove( str.Length-1, 1 );\r
+\r
+                       return str.ToString();\r
+               }\r
+\r
+               /// <summary>\r
+               /// Uses the values in the keyValues hash to create a\r
+               /// connection string\r
+               /// </summary>\r
+               /// <returns></returns>\r
+               public string CreateConnectionString()\r
+               {\r
+                       string cStr = String.Empty;\r
+\r
+                       Hashtable values = (Hashtable)keyValues.Clone();\r
+                       Hashtable defaultValues = GetDefaultValues();\r
+\r
+                       if (!PersistSecurityInfo && values.Contains("password") )\r
+                               values.Remove( "password" );\r
+\r
+                       // we always return the server key.  It's not needed but \r
+                       // seems weird for it not to be there.\r
+                       cStr = "server=" + values["host"] + ";";\r
+                       values.Remove("server");\r
+\r
+                       foreach (string key in values.Keys)\r
+                       {\r
+                               if (!values[key].Equals( defaultValues[key]))\r
+                                       cStr += key + "=" + values[key] + ";";\r
+                       }\r
+\r
+                       return cStr;\r
+               }\r
+\r
+               protected override Hashtable GetDefaultValues()\r
+               {\r
+                       defaults = base.GetDefaultValues();\r
+                       if (defaults == null)\r
+                       {\r
+                               defaults = new Hashtable();\r
+                               defaults["host"] = "localhost";\r
+                               defaults["connect lifetime"] = 0;\r
+                               defaults["user id"] = String.Empty;\r
+                               defaults["password"] = String.Empty;\r
+                               defaults["pooling"] = true;\r
+                               defaults["min pool size"] = 0;\r
+                               defaults["protocol"] = ConnectionProtocol.Sockets;\r
+                               defaults["max pool size"] = 100;\r
+                               defaults["connect timeout"] = 15;\r
+                               defaults["port"] = 3306;\r
+                               defaults["useSSL"] = false;\r
+                               defaults["compress"] = false;\r
+                               defaults["persist Security Info"] = false;\r
+                       }\r
+                       return (Hashtable)defaults.Clone();\r
+               }\r
+\r
+               protected override bool ConnectionParameterParsed(Hashtable hash, string key, string value)\r
+               {\r
+                       switch (key.ToLower()) \r
+                       {\r
+                               case "use compression":\r
+                               case "compress":\r
+                                       hash["compress"] = \r
+                                               value.ToLower() == "yes" || value.ToLower() == "true";\r
+                                       return true;\r
+\r
+                               case "protocol":\r
+                                       if (value == "socket" || value == "tcp")\r
+                                               hash["protocol"] = ConnectionProtocol.Sockets;\r
+                                       else if (value == "pipe")\r
+                                               hash["protocol"] = ConnectionProtocol.NamedPipe;\r
+                                       else if (value == "unix")\r
+                                               hash["protocol"] = ConnectionProtocol.UnixSocket;\r
+                                       return true;\r
+\r
+                               case "use pipe":\r
+                               case "pipe":\r
+                                       hash["use pipe"] = value;\r
+                                       return true;\r
+                       }\r
+\r
+                       if (! base.ConnectionParameterParsed(hash, key, value))\r
+                               throw new ArgumentException("Keyword not supported: '" + key + "'");\r
+                       return true;\r
+               }\r
+\r
+       }\r
+}\r
index fec7dfea8bcff77b01e34dc85b4b4f66cb03ee86..7e51bd04da7157aeda1167c2491017816cf2d2f2 100755 (executable)
-// ByteFX.Data data access components for .Net
-// Copyright (C) 2002-2003  ByteFX, Inc.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// 
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-// 
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-using System;
-using System.Net;
-using System.Net.Sockets;
-using System.IO;
-using ICSharpCode.SharpZipLib.Zip.Compression;
-using System.Security.Cryptography;
-using ByteFX.Data.Common;
-using System.Text;
-
-namespace ByteFX.Data.MySqlClient
-{
-       /// <summary>
-       /// Summary description for Driver.
-       /// </summary>
-       internal class Driver
-       {
-               protected const int HEADER_LEN = 4;
-               protected const int MIN_COMPRESS_LENGTH = 50;
-
-               protected MySqlStream           stream;
-               protected Encoding                      encoding;
-               protected byte                          packetSeq;
-               protected long                          maxPacketSize;
-               protected Packet                        peekedPacket = null;
-               protected ByteFX.Data.Common.Version    serverVersion;
-               protected bool                          isOpen;
-               protected string                        versionString;
-
-               int             protocol;
-               uint    threadID;
-               String  encryptionSeed;
-               int             serverCaps;
-               bool    useCompression = false;
-
-
-               public Driver()
-               {
-                       packetSeq = 0;
-                       encoding = System.Text.Encoding.Default;
-                       isOpen = false;
-               }
-
-               public Encoding Encoding 
-               {
-                       get { return encoding; }
-                       set { encoding = value; }
-               }
-
-               public long MaxPacketSize 
-               {
-                       get { return maxPacketSize; }
-                       set { maxPacketSize = value; }
-               }
-
-               public string Version 
-               {
-                       get { return versionString; }
-               }
-
-               public void Open( MySqlConnectionString settings )
-               {
-                       stream = new MySqlStream( settings.Host, settings.Port, 30, settings.ConnectTimeout );
-
-                       Packet packet = ReadPacket();
-
-                       // read off the protocol version
-                       protocol = packet.ReadByte();
-                       versionString = packet.ReadString();
-                       serverVersion = ByteFX.Data.Common.Version.Parse( versionString );
-                       threadID = (uint)packet.ReadInteger(4);
-                       encryptionSeed = packet.ReadString();
-
-                       // read in Server capabilities if they are provided
-                       serverCaps = 0;
-                       if (packet.HasMoreData)
-                               serverCaps = (int)packet.ReadInteger(2);
-
-                       Authenticate( settings.Username, settings.Password, settings.UseCompression );
-                       isOpen = true;
-               }
-
-               private void Authenticate( String userid, String password, bool UseCompression )
-               {
-                       ClientParam clientParam = ClientParam.CLIENT_FOUND_ROWS | ClientParam.CLIENT_LONG_FLAG;
-
-                       if ((serverCaps & (int)ClientParam.CLIENT_COMPRESS) != 0 && UseCompression)
-                       {
-                               clientParam |= ClientParam.CLIENT_COMPRESS;
-                       }
-
-                       clientParam |= ClientParam.CLIENT_LONG_PASSWORD;
-                       clientParam |= ClientParam.CLIENT_LOCAL_FILES;
-//                     if (serverVersion.isAtLeast(4,1,0))
-//                             clientParam |= ClientParam.CLIENT_PROTOCOL_41;
-                       if ( (serverCaps & (int)ClientParam.CLIENT_SECURE_CONNECTION ) != 0 && password.Length > 0 )
-                               clientParam |= ClientParam.CLIENT_SECURE_CONNECTION;
-
-                       int packetLength = userid.Length + 16 + 6 + 4;  // Passwords can be 16 chars long
-
-                       Packet packet = new Packet();// packetLength );
-
-                       if ((clientParam & ClientParam.CLIENT_PROTOCOL_41) != 0)
-                       {
-                               packet.WriteInteger( (int)clientParam, 4 );
-                               packet.WriteInteger( (256*256*256)-1, 4 );
-                       }
-                       else
-                       {
-                               packet.WriteInteger( (int)clientParam, 2 );
-                               packet.WriteInteger( 255*255*255, 3 );
-                       }
-
-                       packet.WriteString( userid, encoding  );
-                       if ( (clientParam & ClientParam.CLIENT_SECURE_CONNECTION ) != 0 )
-                       {
-                               // use the new authentication system
-                               AuthenticateSecurely( packet, password );
-                       }
-                       else
-                       {
-                               // use old authentication system
-                               packet.WriteString( EncryptPassword(password, encryptionSeed, protocol > 9), encoding );
-                               SendPacket(packet);
-                       }
-
-                       packet = ReadPacket();
-                       if ((clientParam & ClientParam.CLIENT_COMPRESS) != 0)
-                               useCompression = true;
-               }
-
-               /// <summary>
-               /// AuthenticateSecurity implements the new 4.1 authentication scheme
-               /// </summary>
-               /// <param name="packet">The in-progress packet we use to complete the authentication</param>
-               /// <param name="password">The password of the user to use</param>
-               private void AuthenticateSecurely( Packet packet, string password )
-               {
-                       packet.WriteString("xxxxxxxx", encoding );
-                       SendPacket(packet);
-
-                       packet = ReadPacket();
-
-                       // compute pass1 hash
-                       string newPass = password.Replace(" ","").Replace("\t","");
-                       SHA1 sha = new SHA1CryptoServiceProvider(); 
-                       byte[] firstPassBytes = sha.ComputeHash( System.Text.Encoding.Default.GetBytes(newPass));
-
-                       byte[] salt = packet.GetBuffer();
-                       byte[] input = new byte[ firstPassBytes.Length + 4 ];
-                       salt.CopyTo( input, 0 );
-                       firstPassBytes.CopyTo( input, 4 );
-                       byte[] outPass = new byte[100];
-                       byte[] secondPassBytes = sha.ComputeHash( input );
-
-                       byte[] cryptSalt = new byte[20];
-                       Security.ArrayCrypt( salt, 4, cryptSalt, 0, secondPassBytes, 20 );
-
-                       Security.ArrayCrypt( cryptSalt, 0, firstPassBytes, 0, firstPassBytes, 20 );
-
-                       // send the packet
-                       packet = new Packet();
-                       packet.Write( firstPassBytes, 0, 20 );
-                       SendPacket(packet);
-               }
-
-               /// <summary>
-               /// 
-               /// </summary>
-               private Packet ReadRawPacket()
-               {
-                       int packetLength = stream.ReadInt24();
-                       int unCompressedLen = 0;
-
-                       // read the packet sequence and make sure it makes sense
-                       byte seq = (byte)stream.ReadByte();
-                       if (seq != packetSeq) 
-                               throw new MySqlException("Unknown transmission status: sequence out of order");
-       
-                       if (useCompression) 
-                               unCompressedLen = stream.ReadInt24();
-
-                       byte[] buffer;
-                       if (useCompression && unCompressedLen > 0)
-                       {
-                               byte[] compressed_buffer = new Byte[packetLength];
-                               buffer = new Byte[unCompressedLen];
-
-                               // read in the compressed data
-                               stream.Read( compressed_buffer, 0, packetLength );
-
-                               // inflate it
-                               Inflater i = new Inflater();
-                               i.SetInput( compressed_buffer );
-                               i.Inflate( buffer );
-                       }
-                       else 
-                       {
-                               buffer = new Byte[packetLength];
-                               stream.Read( buffer, 0, packetLength);
-                       }
-
-                       packetSeq++;
-                       Packet packet = new Packet( buffer );
-                       packet.Encoding = encoding;
-                       return packet;
-               }
-
-               /// <summary>
-               /// 
-               /// </summary>
-               public void SendFileToServer()
-               {
-               }
-
-               public void ClearPeekedPacket()
-               {
-                       peekedPacket = null;
-               }
-
-               /// <summary>
-               /// 
-               /// </summary>
-               /// <returns></returns>
-               public Packet PeekPacket()
-               {
-                       // we can peek the same packet more than once
-                       if (peekedPacket != null)
-                               return peekedPacket;
-
-                       peekedPacket = ReadPacket();
-                       return peekedPacket;
-               }
-
-               /// <summary>
-               /// 
-               /// </summary>
-               /// <returns></returns>
-               public Packet ReadPacket()
-               {
-                       // if we have a peeked packet, return it now
-                       if (peekedPacket != null) 
-                       {
-                               Packet p = peekedPacket;
-                               peekedPacket = null;
-                               return p;
-                       }
-
-                       Packet packet = ReadRawPacket();
-
-                       // if this is an error packet, then throw the exception
-                       if (packet[0] == 0xff)
-                       {
-                               packet.ReadByte();
-                               int errorCode = (int)packet.ReadInteger(2);
-                               string msg = packet.ReadString();
-                               throw new MySqlException( msg, errorCode );
-                       }
-
-                       return packet;
-               }
-
-               /// <summary>
-               /// 
-               /// </summary>
-               /// <returns></returns>
-/*             protected byte[] CompressPacket(Packet packet)
-               {
-                       // compress the entire packet except the length
-
-                       // make sure we are using a packet prep'ed for compression
-                       // and that our packet is large enough to warrant compression
-                       // re: my_compress.c from mysql src
-                       int offset = HEADER_LEN + COMPRESS_HEADER_LEN;
-                       int original_len = (int)(_packet.Length - offset);
-                       if (original_len < MIN_COMPRESS_LEN) return 0;
-
-                       byte[] packetData = _packet.ToArray();
-
-                       byte[] output = new Byte[ original_len * 2 ];
-                       Deflater d = new Deflater();
-                       d.SetInput( packetData, offset, original_len );
-                       d.Finish();
-                       int comp_len = d.Deflate( output, offset, output.Length - offset  );
-
-                       if (comp_len > original_len) return 0;
-                       _packet = new MemoryStream( output, 0, comp_len + offset );
-                       return (int)comp_len;
-               }
-*/
-               protected byte[] CompressPacket(Packet packet)
-               {
-                       if (packet.Length < MIN_COMPRESS_LENGTH) return null;
-
-                       byte[] compressed_buffer = new byte[packet.Length * 2];
-                       Deflater deflater = new Deflater();
-                       deflater.SetInput( packet.GetBuffer(), 0, packet.Length );
-                       deflater.Finish();
-                       int comp_len = deflater.Deflate( compressed_buffer, 0, compressed_buffer.Length );
-                       if (comp_len > packet.Length) return null;
-                       return compressed_buffer;
-               }
-
-               protected void SendPacket(Packet packet)
-               {
-                       Packet header = null;
-                       byte[] buffer = null;
-
-                       if (useCompression)
-                       {
-                               byte[] compressed_bytes = CompressPacket(packet);
-                               header = new Packet();
-                               
-                               // if we succeeded in compressing
-                               if (compressed_bytes != null) 
-                               {
-                                       header.WriteInteger( compressed_bytes.Length, 3 );
-                                       header.WriteByte( packetSeq );
-                                       header.WriteInteger( packet.Length + HEADER_LEN, 3 );
-                                       buffer = compressed_bytes;
-                               }
-                               else
-                               {
-                                       header.WriteInteger( packet.Length + HEADER_LEN, 3 );
-                                       header.WriteByte( packetSeq );
-                                       header.WriteInteger( 0, 3 );
-                                       buffer = packet.GetBuffer();
-                               }
-                               // now write the internal header
-                               header.WriteInteger( packet.Length, 3 );
-                               header.WriteByte( 0 );
-                       }
-                       else 
-                       {
-                               buffer = packet.GetBytes( packetSeq );
-                       }
-                       packetSeq++;
-
-                       // send the data to eth server
-                       int start = 0;
-                       if (! useCompression) start = 3;
-                       stream.Write( buffer, start, packet.Length - start ); 
-                       stream.Flush();
-               }
-
-
-               public void Close() 
-               {
-                       if (stream != null)
-                               stream.Close();
-               }
-
-
-               /// <summary>
-               /// Sends the specified command to the database
-               /// </summary>
-               /// <param name="command">Command to execute</param>
-               /// <param name="text">Text attribute of command</param>
-               /// <returns>Result packet returned from database server</returns>
-               public void SendCommand( DBCmd command, String text ) 
-               {
-                       Packet packet = new Packet();
-                       packetSeq = 0;
-                       packet.WriteByte( (byte)command );
-                       packet.WriteStringNoNull( text, encoding );
-                       SendPacket(packet);
-                       
-                       packet = ReadPacket();
-                       if (packet[0] != 0)
-                               throw new MySqlException("SendCommand failed for command " + text );
-               }
-
-               /// <summary>
-               /// SendQuery sends a byte array of SQL to the server
-               /// </summary>
-               /// <param name="sql"></param>
-               /// <returns>A packet containing the bytes returned by the server</returns>
-               public Packet SendQuery( byte[] sql )
-               {
-                       string s = encoding.GetString(sql);
-
-                       Packet packet = new Packet();
-                       packetSeq = 0;
-                       packet.WriteByte( (byte)DBCmd.QUERY );
-                       packet.Write( sql, 0, sql.Length );
-
-                       SendPacket( packet );
-                       return ReadPacket();
-               }
-
-               
-
-               public Packet SendSql( byte[] bytes )
-               {
-                       Packet packet = new Packet();
-                       packetSeq = 0;
-                       packet.WriteByte( (byte)DBCmd.QUERY );
-                       packet.Write( bytes, 0, bytes.Length );
-
-                       SendPacket( packet );
-                       packet = ReadPacket();
-                       return packet;
-               }
-
-               #region PasswordStuff
-               private static double rand(ref long seed1, ref long seed2)
-               {
-                       seed1 = (seed1 * 3) + seed2;
-                       seed1 %= 0x3fffffff;
-                       seed2 = (seed1 + seed2 + 33) % 0x3fffffff;
-                       return (seed1 / (double)0x3fffffff);
-               }
-
-               /// <summary>
-               /// Encrypts a password using the MySql encryption scheme
-               /// </summary>
-               /// <param name="password">The password to encrypt</param>
-               /// <param name="message">The encryption seed the server gave us</param>
-               /// <param name="new_ver">Indicates if we should use the old or new encryption scheme</param>
-               /// <returns></returns>
-               public static String EncryptPassword(String password, String message, bool new_ver)
-               {
-                       if (password == null || password.Length == 0)
-                               return password;
-
-                       long[] hash_message = Hash(message);
-                       long[] hash_pass = Hash(password);
-
-                       long seed1 = (hash_message[0]^hash_pass[0]) % 0x3fffffff;
-                       long seed2 = (hash_message[1]^hash_pass[1]) % 0x3fffffff;
-
-                       char[] scrambled = new char[message.Length];
-                       for (int x=0; x < message.Length; x++) 
-                       {
-                               double r = rand(ref seed1, ref seed2);
-                               scrambled[x] = (char)(Math.Floor(r*31) + 64);
-                       }
-
-                       if (new_ver)
-                       {                                               /* Make it harder to break */
-                               char extra = (char)Math.Floor( rand(ref seed1, ref seed2) * 31 );
-                               for (int x=0; x < scrambled.Length; x++)
-                                       scrambled[x] ^= extra;
-                       }
-
-                       return new string(scrambled);
-               }
-
-               /// <summary>
-               /// 
-               /// </summary>
-               /// <param name="P"></param>
-               /// <returns></returns>
-               static long[] Hash(String P) 
-               {
-                       long val1 = 1345345333;
-                       long val2 = 0x12345671;
-                       long inc  = 7;
-
-                       for (int i=0; i < P.Length; i++) 
-                       {
-                               if (P[i] == ' ' || P[i] == '\t') continue;
-                               long temp = (long)(0xff & P[i]);
-                               val1 ^= (((val1 & 63)+inc)*temp) + (val1 << 8);
-                               val2 += (val2 << 8) ^ val1;
-                               inc += temp;
-                       }
-
-                       long[] hash = new long[2];
-                       hash[0] = val1 & 0x7fffffff;
-                       hash[1] = val2 & 0x7fffffff;
-                       return hash;
-               }
-               #endregion
-       }
-}
+// ByteFX.Data data access components for .Net\r
+// Copyright (C) 2002-2003  ByteFX, Inc.\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License, or (at your option) any later version.\r
+// \r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+// Lesser General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+\r
+using System;\r
+using System.Net;\r
+using System.Net.Sockets;\r
+using System.IO;\r
+using ICSharpCode.SharpZipLib.Zip.Compression;\r
+using ICSharpCode.SharpZipLib.Zip.Compression.Streams;\r
+using System.Security.Cryptography;\r
+using ByteFX.Data.Common;\r
+using System.Collections;\r
+using System.Text;\r
+\r
+namespace ByteFX.Data.MySqlClient\r
+{\r
+       /// <summary>\r
+       /// Summary description for Driver.\r
+       /// </summary>\r
+       internal class Driver\r
+       {\r
+               protected const int HEADER_LEN = 4;\r
+               protected const int MIN_COMPRESS_LENGTH = 50;\r
+               protected const int MAX_PACKET_SIZE = 256*256*256-1;\r
+\r
+               protected Stream                        stream;\r
+               protected BufferedStream        writer;\r
+               protected Encoding                      encoding;\r
+               protected byte                          packetSeq;\r
+               protected long                          maxPacketSize;\r
+               protected DBVersion                     serverVersion;\r
+               protected bool                          isOpen;\r
+               protected string                        versionString;\r
+               protected Packet                        peekedPacket;\r
+\r
+               protected int                           protocol;\r
+               protected uint                          threadID;\r
+               protected String                        encryptionSeed;\r
+               protected int                           serverCaps;\r
+               protected bool                          useCompression = false;\r
+\r
+\r
+               public Driver()\r
+               {\r
+                       packetSeq = 0;\r
+                       encoding = System.Text.Encoding.Default;\r
+                       isOpen = false;\r
+               }\r
+\r
+               public Encoding Encoding \r
+               {\r
+                       get { return encoding; }\r
+                       set { encoding = value; }\r
+               }\r
+\r
+               public long MaxPacketSize \r
+               {\r
+                       get { return maxPacketSize; }\r
+                       set { maxPacketSize = value; }\r
+               }\r
+\r
+               public string VersionString \r
+               {\r
+                       get { return versionString; }\r
+               }\r
+\r
+               public DBVersion Version \r
+               {\r
+                       get { return serverVersion; }\r
+               }\r
+\r
+               public void Open( MySqlConnectionString settings )\r
+               {\r
+                       // connect to one of our specified hosts\r
+                       try \r
+                       {\r
+                               StreamCreator sc = new StreamCreator( settings.Server, settings.Port, settings.PipeName );\r
+                               stream = sc.GetStream( settings.ConnectionTimeout );\r
+                       }\r
+                       catch (Exception ex)\r
+                       {\r
+                               throw new MySqlException("Unable to connect to any of the specified MySQL hosts", ex);\r
+                       }\r
+\r
+                       if (stream == null) \r
+                               throw new MySqlException("Unable to connect to any of the specified MySQL hosts");\r
+\r
+                       writer = new BufferedStream( stream );\r
+                       // read off the welcome packet and parse out it's values\r
+                       Packet packet = ReadPacket();\r
+                       protocol = packet.ReadByte();\r
+                       versionString = packet.ReadString();\r
+                       serverVersion = DBVersion.Parse( versionString );\r
+                       threadID = (uint)packet.ReadInteger(4);\r
+                       encryptionSeed = packet.ReadString();\r
+\r
+                       // read in Server capabilities if they are provided\r
+                       serverCaps = 0;\r
+                       if (packet.HasMoreData)\r
+                               serverCaps = (int)packet.ReadInteger(2);\r
+\r
+                       Authenticate( settings.UserId, settings.Password, settings.UseCompression );\r
+\r
+                       // if we are using compression, then we use our CompressedStream class\r
+                       // to hide the ugliness of managing the compression\r
+                       if (settings.UseCompression)\r
+                       {\r
+                               stream = new CompressedStream( stream );\r
+                               writer = new BufferedStream( stream );\r
+                       }\r
+\r
+                       isOpen = true;\r
+               }\r
+\r
+               private Packet CreatePacket( byte[] buf )\r
+               {\r
+                       if (buf == null)\r
+                               return new Packet( serverVersion.isAtLeast(3, 22, 5) );\r
+                       return new Packet( buf, serverVersion.isAtLeast(3, 22, 5 ));\r
+               }\r
+\r
+               private void Authenticate( String userid, String password, bool UseCompression )\r
+               {\r
+                       ClientParam clientParam = ClientParam.CLIENT_FOUND_ROWS | ClientParam.CLIENT_LONG_FLAG;\r
+\r
+                       if ((serverCaps & (int)ClientParam.CLIENT_COMPRESS) != 0 && UseCompression)\r
+                       {\r
+                               clientParam |= ClientParam.CLIENT_COMPRESS;\r
+                       }\r
+\r
+                       clientParam |= ClientParam.CLIENT_LONG_PASSWORD;\r
+                       clientParam |= ClientParam.CLIENT_LOCAL_FILES;\r
+//                     if (serverVersion.isAtLeast(4,1,0))\r
+//                             clientParam |= ClientParam.CLIENT_PROTOCOL_41;\r
+//                     if ( (serverCaps & (int)ClientParam.CLIENT_SECURE_CONNECTION ) != 0 && password.Length > 0 )\r
+//                             clientParam |= ClientParam.CLIENT_SECURE_CONNECTION;\r
+\r
+                       int packetLength = userid.Length + 16 + 6 + 4;  // Passwords can be 16 chars long\r
+\r
+                       Packet packet = CreatePacket(null);\r
+\r
+                       if ((clientParam & ClientParam.CLIENT_PROTOCOL_41) != 0)\r
+                       {\r
+                               packet.WriteInteger( (int)clientParam, 4 );\r
+                               packet.WriteInteger( (256*256*256)-1, 4 );\r
+                       }\r
+                       else\r
+                       {\r
+                               packet.WriteInteger( (int)clientParam, 2 );\r
+                               packet.WriteInteger( 255*255*255, 3 );\r
+                       }\r
+\r
+                       packet.WriteString( userid, encoding  );\r
+                       if ( (clientParam & ClientParam.CLIENT_SECURE_CONNECTION ) != 0 )\r
+                       {\r
+                               // use the new authentication system\r
+                               AuthenticateSecurely( packet, password );\r
+                       }\r
+                       else\r
+                       {\r
+                               // use old authentication system\r
+                               packet.WriteString( EncryptPassword(password, encryptionSeed, protocol > 9), encoding );\r
+                               // pad zeros out to packetLength for auth\r
+                               for (int i=0; i < (packetLength-packet.Length); i++)\r
+                                       packet.WriteByte(0);\r
+                               SendPacket(packet);\r
+                       }\r
+\r
+                       packet = ReadPacket();\r
+                       if ((clientParam & ClientParam.CLIENT_COMPRESS) != 0)\r
+                               useCompression = true;\r
+               }\r
+\r
+               /// <summary>\r
+               /// AuthenticateSecurity implements the new 4.1 authentication scheme\r
+               /// </summary>\r
+               /// <param name="packet">The in-progress packet we use to complete the authentication</param>\r
+               /// <param name="password">The password of the user to use</param>\r
+               private void AuthenticateSecurely( Packet packet, string password )\r
+               {\r
+                       packet.WriteString("xxxxxxxx", encoding );\r
+                       SendPacket(packet);\r
+\r
+                       packet = ReadPacket();\r
+\r
+                       // compute pass1 hash\r
+                       string newPass = password.Replace(" ","").Replace("\t","");\r
+                       SHA1 sha = new SHA1CryptoServiceProvider(); \r
+                       byte[] firstPassBytes = sha.ComputeHash( System.Text.Encoding.Default.GetBytes(newPass));\r
+\r
+                       byte[] salt = packet.GetBuffer();\r
+                       byte[] input = new byte[ firstPassBytes.Length + 4 ];\r
+                       salt.CopyTo( input, 0 );\r
+                       firstPassBytes.CopyTo( input, 4 );\r
+                       byte[] outPass = new byte[100];\r
+                       byte[] secondPassBytes = sha.ComputeHash( input );\r
+\r
+                       byte[] cryptSalt = new byte[20];\r
+                       Security.ArrayCrypt( salt, 4, cryptSalt, 0, secondPassBytes, 20 );\r
+\r
+                       Security.ArrayCrypt( cryptSalt, 0, firstPassBytes, 0, firstPassBytes, 20 );\r
+\r
+                       // send the packet\r
+                       packet = CreatePacket(null);\r
+                       packet.Write( firstPassBytes, 0, 20 );\r
+                       SendPacket(packet);\r
+               }\r
+\r
+\r
+               /// <summary>\r
+               /// \r
+               /// </summary>\r
+               /// <returns></returns>\r
+               public Packet PeekPacket()\r
+               {\r
+                       if (peekedPacket != null)\r
+                               return peekedPacket;\r
+\r
+                       peekedPacket = ReadPacket();\r
+                       return peekedPacket;\r
+               }\r
+\r
+               /// <summary>\r
+               /// ReadBuffer continuously loops until it has read the entire\r
+               /// requested data\r
+               /// </summary>\r
+               /// <param name="buf">Buffer to read data into</param>\r
+               /// <param name="offset">Offset to place the data</param>\r
+               /// <param name="length">Number of bytes to read</param>\r
+               private void ReadBuffer( byte[] buf, int offset, int length )\r
+               {\r
+                       while (length > 0)\r
+                       {\r
+                               int amountRead = stream.Read( buf, offset, length );\r
+                               if (amountRead == 0)\r
+                                       throw new MySqlException("Unexpected end of data encountered");\r
+                               length -= amountRead;\r
+                               offset += amountRead;\r
+                       }\r
+               }\r
+\r
+               private Packet ReadPacketFromServer()\r
+               {\r
+                       int len = stream.ReadByte() + (stream.ReadByte() << 8) +\r
+                               (stream.ReadByte() << 16);\r
+                       byte seq = (byte)stream.ReadByte();\r
+                       byte[] buf = new byte[ len ];\r
+                       ReadBuffer( buf, 0, len );\r
+\r
+                       if (seq != packetSeq) \r
+                               throw new MySqlException("Unknown transmission status: sequence out of order");\r
+                       packetSeq++;\r
+\r
+                       Packet p = CreatePacket(buf);\r
+                       p.Encoding = this.Encoding;\r
+                       if (p.Length == MAX_PACKET_SIZE && serverVersion.isAtLeast(4,0,0)) \r
+                               p.Append( ReadPacketFromServer() );\r
+                       return p;\r
+               }\r
+\r
+               /// <summary>\r
+               /// Reads a single packet off the stream\r
+               /// </summary>\r
+               /// <returns></returns>\r
+               public Packet ReadPacket()\r
+               {\r
+                       // if we have peeked at a packet, then return it\r
+                       if (peekedPacket != null)\r
+                       {\r
+                               Packet packet = peekedPacket;\r
+                               peekedPacket = null;\r
+                               return packet;\r
+                       }\r
+\r
+                       Packet p = ReadPacketFromServer();\r
+\r
+                       // if this is an error packet, then throw the exception\r
+                       if (p[0] == 0xff)\r
+                       {\r
+                               p.ReadByte();\r
+                               int errorCode = (int)p.ReadInteger(2);\r
+                               string msg = p.ReadString();\r
+                               throw new MySqlException( msg, errorCode );\r
+                       }\r
+                       \r
+                       return p;\r
+               }\r
+\r
+               protected MemoryStream CompressBuffer(byte[] buf, int index, int length)\r
+               {\r
+\r
+                       if (length < MIN_COMPRESS_LENGTH) return null;\r
+\r
+                       MemoryStream ms = new MemoryStream(buf.Length);\r
+                       DeflaterOutputStream dos = new DeflaterOutputStream(ms);\r
+\r
+                       dos.WriteByte( (byte)(length & 0xff ));\r
+                       dos.WriteByte( (byte)((length >> 8) & 0xff ));\r
+                       dos.WriteByte( (byte)((length >> 16) & 0xff ));\r
+                       dos.WriteByte( 0 );\r
+\r
+                       dos.Write( buf, index, length );\r
+                       dos.Finish();\r
+                       if (ms.Length > length+4) return null;\r
+                       return ms;\r
+               }\r
+\r
+               private void WriteInteger( int v, int numbytes )\r
+               {\r
+                       int val = v;\r
+\r
+                       if (numbytes < 1 || numbytes > 4) \r
+                               throw new ArgumentOutOfRangeException("Wrong byte count for WriteInteger");\r
+\r
+                       for (int x=0; x < numbytes; x++)\r
+                       {\r
+                               writer.WriteByte( (byte)(val&0xff) );\r
+                               val >>= 8;\r
+                       }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Send a buffer to the server in a compressed form\r
+               /// </summary>\r
+               /// <param name="buf">Byte buffer to send</param>\r
+               /// <param name="index">Location in buffer to start sending</param>\r
+               /// <param name="length">Amount of data to send</param>\r
+               protected void SendCompressedBuffer(byte[] buf, int index, int length)\r
+               {\r
+                       MemoryStream compressed_bytes = CompressBuffer(buf, index, length);\r
+                       int comp_len = compressed_bytes == null ? length+HEADER_LEN : (int)compressed_bytes.Length;\r
+                       int ucomp_len = compressed_bytes == null ? 0 : length+HEADER_LEN;\r
+\r
+                       WriteInteger( comp_len, 3 );\r
+                       writer.WriteByte( packetSeq++ );\r
+                       WriteInteger( ucomp_len, 3 );\r
+                       if (compressed_bytes != null)\r
+                               writer.Write( compressed_bytes.GetBuffer(), 0, (int)compressed_bytes.Length );\r
+                       else \r
+                       {\r
+                               WriteInteger( length, 3 );      \r
+                               writer.WriteByte( 0 );\r
+                               writer.Write( buf, index, length );\r
+                       }\r
+                       stream.Flush();\r
+               }\r
+\r
+               protected void SendBuffer( byte[] buf, int offset, int length )\r
+               {\r
+                       while (length > 0)\r
+                       {\r
+                               int amount = Math.Min( 1024, length );\r
+                               writer.Write( buf, offset, amount );\r
+                               writer.Flush();\r
+                               offset += amount;\r
+                               length -= amount;\r
+                       }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Send a single packet to the server.\r
+               /// </summary>\r
+               /// <param name="packet">Packet to send to the server</param>\r
+               /// <remarks>This method will send a single packet to the server\r
+               /// possibly breaking the packet up into smaller packets that are\r
+               /// smaller than max_allowed_packet.  This method will always send at\r
+               /// least one packet to the server</remarks>\r
+        protected void SendPacket(Packet packet)\r
+               {\r
+                       byte[]  buf = packet.GetBuffer();\r
+                       int             len = packet.Length;\r
+                       int             index = 0;\r
+                       bool    oneSent = false;\r
+\r
+                       // make sure we are not trying to send too much\r
+                       if (packet.Length > maxPacketSize && maxPacketSize > 0)\r
+                               throw new MySqlException("Packet size too large.  This MySQL server cannot accept rows larger than " + maxPacketSize + " bytes.");\r
+\r
+                       try \r
+                       {\r
+                               while (len > 0 || ! oneSent) \r
+                               {\r
+                                       int lenToSend = Math.Min( len, MAX_PACKET_SIZE );\r
+\r
+                                       // send the data\r
+                                       if (useCompression)\r
+                                               SendCompressedBuffer( buf, index, lenToSend );\r
+                                       else \r
+                                       {\r
+                                               WriteInteger( lenToSend, 3 );\r
+                                               writer.WriteByte( packetSeq++ );\r
+                                               writer.Write( buf, index, lenToSend );\r
+                                               writer.Flush();\r
+                                       }\r
+\r
+                                       len -= lenToSend;\r
+                                       index += lenToSend;\r
+                                       oneSent = true;\r
+                               }\r
+                               writer.Flush();\r
+                       }\r
+                       catch (Exception ex)\r
+                       {\r
+                               Console.WriteLine( ex.Message );\r
+                       }\r
+               }\r
+\r
+\r
+               public void Close() \r
+               {\r
+                       if (stream != null)\r
+                               stream.Close();\r
+               }\r
+\r
+\r
+               /// <summary>\r
+               /// Sends the specified command to the database\r
+               /// </summary>\r
+               /// <param name="command">Command to execute</param>\r
+               /// <param name="text">Text attribute of command</param>\r
+               /// <returns>Result packet returned from database server</returns>\r
+               public void Send( DBCmd command, String text ) \r
+               {\r
+                       CommandResult result = Send( command, this.Encoding.GetBytes( text ) );\r
+                       if (result.IsResultSet)\r
+                               throw new MySqlException("SendCommand failed for command " + text );\r
+               }\r
+\r
+               public CommandResult Send( DBCmd cmd, byte[] bytes )\r
+               {\r
+//                     string s = Encoding.GetString( bytes );\r
+\r
+                       Packet packet = CreatePacket(null);\r
+                       packetSeq = 0;\r
+                       packet.WriteByte( (byte)cmd );\r
+                       if (bytes != null)\r
+                               packet.Write( bytes, 0, bytes.Length );\r
+\r
+                       SendPacket( packet );\r
+                       packet = ReadPacket();\r
+\r
+                       // first check to see if this is a LOAD DATA LOCAL callback\r
+                       // if so, send the file and then read the results\r
+                       long fieldcount = packet.ReadLenInteger();\r
+                       if (fieldcount == Packet.NULL_LEN)\r
+                       {\r
+                               string filename = packet.ReadString();\r
+                               SendFileToServer( filename );\r
+                               packet = ReadPacket();\r
+                       }\r
+                       else\r
+                               packet.Position = 0;\r
+\r
+                       return new CommandResult(packet, this);\r
+               }\r
+\r
+               /// <summary>\r
+               /// Sends the specified file to the server. \r
+               /// This supports the LOAD DATA LOCAL INFILE\r
+               /// </summary>\r
+               /// <param name="filename"></param>\r
+               private void SendFileToServer( string filename )\r
+               {\r
+                       Packet          p = CreatePacket(null);\r
+                       byte[]          buffer = new byte[4092];\r
+                       FileStream      fs = null;\r
+                       try \r
+                       {\r
+                               fs = new FileStream( filename, FileMode.Open );\r
+                               int count = fs.Read( buffer, 0, buffer.Length );\r
+                               while (count != 0) \r
+                               {\r
+                                       if ((p.Length + count) > MAX_PACKET_SIZE)\r
+                                       {\r
+                                               SendPacket( p );\r
+                                               p.Clear();\r
+                                       }\r
+                                       p.Write( buffer, 0, count );\r
+                                       count = fs.Read( buffer, 0, buffer.Length );\r
+                               }\r
+                               fs.Close();\r
+\r
+                               // send any remaining data\r
+                               if (p.Length > 0) \r
+                               {\r
+                                       SendPacket(p);\r
+                                       p.Clear();\r
+                               }\r
+                       }\r
+                       catch (Exception ex)\r
+                       {\r
+                               throw new MySqlException("Error during LOAD DATA LOCAL INFILE", ex);\r
+                       }\r
+                       finally \r
+                       {\r
+                               if (fs != null)\r
+                                       fs.Close();\r
+                               // empty packet signals end of file\r
+                               p.Clear();\r
+                               SendPacket(p);\r
+                       }\r
+               }\r
+\r
+               #region PasswordStuff\r
+               private static double rand(ref long seed1, ref long seed2)\r
+               {\r
+                       seed1 = (seed1 * 3) + seed2;\r
+                       seed1 %= 0x3fffffff;\r
+                       seed2 = (seed1 + seed2 + 33) % 0x3fffffff;\r
+                       return (seed1 / (double)0x3fffffff);\r
+               }\r
+\r
+               /// <summary>\r
+               /// Encrypts a password using the MySql encryption scheme\r
+               /// </summary>\r
+               /// <param name="password">The password to encrypt</param>\r
+               /// <param name="message">The encryption seed the server gave us</param>\r
+               /// <param name="new_ver">Indicates if we should use the old or new encryption scheme</param>\r
+               /// <returns></returns>\r
+               public static String EncryptPassword(String password, String message, bool new_ver)\r
+               {\r
+                       if (password == null || password.Length == 0)\r
+                               return password;\r
+\r
+                       long[] hash_message = Hash(message);\r
+                       long[] hash_pass = Hash(password);\r
+\r
+                       long seed1 = (hash_message[0]^hash_pass[0]) % 0x3fffffff;\r
+                       long seed2 = (hash_message[1]^hash_pass[1]) % 0x3fffffff;\r
+\r
+                       char[] scrambled = new char[message.Length];\r
+                       for (int x=0; x < message.Length; x++) \r
+                       {\r
+                               double r = rand(ref seed1, ref seed2);\r
+                               scrambled[x] = (char)(Math.Floor(r*31) + 64);\r
+                       }\r
+\r
+                       if (new_ver)\r
+                       {                                               /* Make it harder to break */\r
+                               char extra = (char)Math.Floor( rand(ref seed1, ref seed2) * 31 );\r
+                               for (int x=0; x < scrambled.Length; x++)\r
+                                       scrambled[x] ^= extra;\r
+                       }\r
+\r
+                       return new string(scrambled);\r
+               }\r
+\r
+               /// <summary>\r
+               /// \r
+               /// </summary>\r
+               /// <param name="P"></param>\r
+               /// <returns></returns>\r
+               static long[] Hash(String P) \r
+               {\r
+                       long val1 = 1345345333;\r
+                       long val2 = 0x12345671;\r
+                       long inc  = 7;\r
+\r
+                       for (int i=0; i < P.Length; i++) \r
+                       {\r
+                               if (P[i] == ' ' || P[i] == '\t') continue;\r
+                               long temp = (long)(0xff & P[i]);\r
+                               val1 ^= (((val1 & 63)+inc)*temp) + (val1 << 8);\r
+                               val2 += (val2 << 8) ^ val1;\r
+                               inc += temp;\r
+                       }\r
+\r
+                       long[] hash = new long[2];\r
+                       hash[0] = val1 & 0x7fffffff;\r
+                       hash[1] = val2 & 0x7fffffff;\r
+                       return hash;\r
+               }\r
+               #endregion\r
+       }\r
+}\r
index 2e8efbc8820608c58277beda40fc6ec23a039fc7..189afae5eec89f8616473876d292053178624309 100755 (executable)
@@ -1,53 +1,63 @@
-// ByteFX.Data data access components for .Net
-// Copyright (C) 2002-2003  ByteFX, Inc.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// 
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-// 
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-using System;
-using System.Runtime.Serialization;
-
-namespace ByteFX.Data.MySqlClient
-{
-       /// <summary>
-       /// The exception that is thrown when MySQL returns an error. This class cannot be inherited.
-       /// </summary>
-       /// <include file='docs/MySqlException.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>
-       [Serializable]
-       public sealed class MySqlException : SystemException
-       {
-               internal MySqlException(string msg) : base(msg)
-               {
-               }
-               
-               internal MySqlException( string msg, Exception ex ) : base(msg, ex)
-               {
-               }
-
-               internal MySqlException() 
-               {
-               }
-
-               internal MySqlException(string msg, int errno) : base(msg)
-               {
-                       
-               }
-
-               internal MySqlException(SerializationInfo info,
-                                       StreamingContext context) : base(info, context)
-               {
-               }
-
-       }
-}
+// ByteFX.Data data access components for .Net\r
+// Copyright (C) 2002-2003  ByteFX, Inc.\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License, or (at your option) any later version.\r
+// \r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+// Lesser General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+\r
+using System;\r
+using System.Runtime.Serialization;\r
+\r
+namespace ByteFX.Data.MySqlClient\r
+{\r
+       /// <summary>\r
+       /// The exception that is thrown when MySQL returns an error. This class cannot be inherited.\r
+       /// </summary>\r
+       /// <include file='docs/MySqlException.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>\r
+       [Serializable]\r
+       public sealed class MySqlException : SystemException\r
+       {\r
+               private int     errorCode;\r
+\r
+               internal MySqlException(string msg) : base(msg)\r
+               {\r
+               }\r
+               \r
+               internal MySqlException( string msg, Exception ex ) : base(msg, ex)\r
+               {\r
+               }\r
+\r
+               internal MySqlException() \r
+               {\r
+               }\r
+\r
+               internal MySqlException(string msg, int errno) : base(msg)\r
+               {\r
+                       errorCode = errno;      \r
+               }\r
+\r
+               internal MySqlException(SerializationInfo info,\r
+                                       StreamingContext context) : base(info, context)\r
+               {\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets a number that identifies the type of error.\r
+               /// </summary>\r
+               public int Number \r
+               {\r
+                       get { return errorCode; }\r
+               }\r
+\r
+       }\r
+}\r
index 4e30648224cbd10f7e0424e263d6aa6d11bcfffa..70aaa93c885585aceefe87bbee8132903db9b667 100755 (executable)
-// ByteFX.Data data access components for .Net
-// Copyright (C) 2002-2003  ByteFX, Inc.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// 
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-// 
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-using System;
-using System.Data;
-using System.Data.SqlTypes;
-using System.Globalization;
-using System.Text;
-
-namespace ByteFX.Data.MySqlClient
-{
-       internal enum ColFlags : int
-       {
-               NOT_NULL                = 1,
-               PRIMARY_KEY             = 2,
-               UNIQUE_KEY              = 4,
-               MULTIPLE_KEY    = 8,
-               BLOB                    = 16,
-               UNSIGNED                = 32,
-               ZERO_FILL               = 64,
-               BINARY                  = 128,
-               ENUM                    = 256,
-               AUTO_INCREMENT  = 512,
-               TIMESTAMP               = 1024,
-               SET                             = 2048,
-               NUMBER                  = 32768
-       };
-       
-       /// <summary>
-       /// Summary description for Field.
-       /// </summary>
-       internal class MySqlField : Common.Field
-       {
-                 MySqlDbType                   colType;
-               public  ColFlags                colFlags;
-               public  int                             colDecimals;
-//             System.Text.Encoding    encoding;
-               private static NumberFormatInfo         numberFormat = null;
-
-
-               public MySqlField()
-               {
-//                     this.encoding = encoding;
-                       if (numberFormat == null)
-                       {
-                               numberFormat = (NumberFormatInfo)NumberFormatInfo.InvariantInfo.Clone();
-                               numberFormat.NumberDecimalSeparator = ".";
-                       }
-               }
-
-               public void ReadSchemaInfo( Packet packet )
-               {       
-                       tableName = packet.ReadLenString();
-                       colName = packet.ReadLenString();
-                       colLen = (int)packet.ReadNBytes();
-                       colType = (MySqlDbType)packet.ReadNBytes();
-                       packet.ReadByte();                                                                      // this is apparently 2 -- not sure what it is for
-                       colFlags = (ColFlags)packet.ReadInteger(2);             //(short)(d.ReadByte() & 0xff);
-                       colDecimals = packet.ReadByte();
-               }
-
-               public object GetValue() 
-               {
-                       return value;
-               }
-
-               public int NumericPrecision()
-               {
-                       if (colType == MySqlDbType.Decimal)
-                               return colLen;
-                       return -1;
-               }
-
-               public int NumericScale()
-               {
-                       if (colType == MySqlDbType.Decimal)
-                               return colDecimals;
-                       return -1;
-               }
-
-               public bool IsAutoIncrement()
-               {
-                       return (colFlags & ColFlags.AUTO_INCREMENT) > 0;
-               }
-
-               public bool IsNumeric()
-               {
-                       return (colFlags & ColFlags.NUMBER) > 0;
-               }
-
-               public bool AllowsNull()
-               {
-                       return (colFlags & ColFlags.NOT_NULL) == 0;
-               }
-
-               public bool IsUnique()
-               {
-                       return (colFlags & ColFlags.UNIQUE_KEY) > 0;
-               }
-
-               public bool IsPrimaryKey()
-               {
-                       return (colFlags & ColFlags.PRIMARY_KEY) > 0;
-               }
-
-               public bool IsBlob() 
-               {
-                       return (colFlags & ColFlags.BLOB) > 0;
-               }
-
-               public bool IsBinary()
-               {
-                       return (colFlags & ColFlags.BINARY) > 0;
-               }
-
-               public bool IsUnsigned()
-               {
-                       return (colFlags & ColFlags.UNSIGNED) > 0;
-               }
-
-               public void SetValueData( Packet p, Encoding encoding )
-               {
-                       int len = p.ReadLenInteger();
-                       if (len == -1)
-                       {
-                               value = DBNull.Value;
-                               return;
-                       }
-
-                       // read in the data
-                       byte[] data = new byte[ len ];
-                       p.Read( data, 0, len );
-
-                       // if it is a blob and binary, then GetBytes is the way to go
-                       if ( IsBlob() && IsBinary() ) 
-                       {
-                               dbType = DbType.Binary;
-                               value = data;
-                               return;
-                       }
-
-                       string sValue = encoding.GetString( data );//Chars(data, offset, count );
-                       //string sValue = new string(_Chars);
-
-                       switch(colType)
-                       {
-                               case MySqlDbType.Byte:
-                                       if (IsUnsigned())
-                                               value = Byte.Parse( sValue );
-                                       else
-                                               value = SByte.Parse( sValue );
-                                       break;
-
-                               case MySqlDbType.Short:
-                                       if (IsUnsigned())
-                                               value = UInt16.Parse( sValue );
-                                       else
-                                               value = Int16.Parse( sValue );
-                                       break;
-                                       
-                               case MySqlDbType.Int : 
-                               case MySqlDbType.Int24:
-                                       if (IsUnsigned())
-                                               value = UInt32.Parse( sValue );
-                                       else
-                                               value = Int32.Parse( sValue );
-                                       break;
-
-                               case MySqlDbType.BigInt:
-                                       if (IsUnsigned())
-                                               value = UInt64.Parse( sValue );
-                                       else
-                                               value = Int64.Parse( sValue );
-                                       break;
-
-                               case MySqlDbType.Decimal:
-                                       value = Decimal.Parse( sValue , numberFormat );
-                                       break;
-
-                               case MySqlDbType.Float:
-                                       value = Convert.ToSingle( sValue, numberFormat );
-                                       break;
-
-                               case MySqlDbType.Double:
-                                       value = Convert.ToDouble( sValue, numberFormat );
-                                       break;
-
-                               case MySqlDbType.Date:
-                                       ParseDateValue( "0000-00-00", "yyyy-MM-dd", sValue );
-                                       break;
-
-                               case MySqlDbType.Datetime:
-                                       ParseDateValue( "0000-00-00 00:00:00", "yyyy-MM-dd HH:mm:ss", sValue );
-                                       break;
-
-                               case MySqlDbType.Time:
-                                       if (sValue.Equals("00:00:00"))
-                                               value = DBNull.Value;
-                                       else
-                                               value = TimeSpan.Parse(sValue);
-                                       break;
-
-                               case MySqlDbType.Timestamp:
-                                       string pattern;
-                                       string null_value = "00000000000000";
-                                       switch (ColumnLength) 
-                                       {
-                                               case 2:  pattern = "yy"; break;
-                                               case 4:  pattern = "yyMM"; break;
-                                               case 6:  pattern = "yyMMdd"; break;
-                                               case 8:  pattern = "yyyyMMdd"; break;
-                                               case 10: pattern = "yyMMddHHmm"; break;
-                                               case 12: pattern = "yyMMddHHmmss"; break;
-                                               case 14: 
-                                               default: pattern = "yyyyMMddHHmmss"; break;
-                                       }
-
-                                       if (ColumnLength > 2 && sValue.Equals( null_value.Substring(0, ColumnLength)))
-                                               value = DBNull.Value;
-                                       else
-                                               value = DateTime.ParseExact( sValue, pattern, new System.Globalization.DateTimeFormatInfo());
-                                       break;
-
-                               case MySqlDbType.String:
-                               case MySqlDbType.VarChar:
-                               case MySqlDbType.Blob:
-                               case MySqlDbType.TinyBlob:
-                               case MySqlDbType.LongBlob:
-                               case MySqlDbType.MediumBlob: 
-                                       value = sValue;
-                                       break;
-
-                               default:
-                                       throw new NotSupportedException();
-                       }
-               }
-
-               protected void ParseDateValue( string nullpattern, string pattern, string data )
-               {
-                       if ( data.Equals (nullpattern) )
-                               value = DBNull.Value;
-                       else
-                               value = DateTime.ParseExact( data, pattern, new System.Globalization.DateTimeFormatInfo());
-               }
-
-               public string GetFieldTypeName() 
-               {
-                       switch (colType) 
-                       {
-                               case MySqlDbType.Decimal:               return "DECIMAL";
-                               case MySqlDbType.Byte:                  return "TINY";
-                               case MySqlDbType.Short:                 return "SHORT";
-                               case MySqlDbType.Int:                   return "INTEGER";
-                               case MySqlDbType.Float:                 return "FLOAT";
-                               case MySqlDbType.Double:                return "DOUBLE";
-                               case MySqlDbType.Null:                  return "NULL";
-                               case MySqlDbType.Timestamp:             return "TIMESTAMP";
-                               case MySqlDbType.BigInt:                return "BIGINT";
-                               case MySqlDbType.Int24:                 return "INT24";
-                               case MySqlDbType.Date:                  return "DATE";
-                               case MySqlDbType.Time:                  return "TIME";
-                               case MySqlDbType.Datetime:              return "DATETIME";
-                               case MySqlDbType.Year:                  return "YEAR";
-                               case MySqlDbType.Newdate:               return "NEWDATE";
-                               case MySqlDbType.Enum:                  return "ENUM";
-                               case MySqlDbType.Set:                   return "SET";
-                               case MySqlDbType.TinyBlob:              return "TINY_BLOB";
-                               case MySqlDbType.MediumBlob:    return "MEDIUM_BLOB";
-                               case MySqlDbType.LongBlob:              return "LONG_BLOB";
-                               case MySqlDbType.Blob:                  return "BLOB";
-                               case MySqlDbType.VarChar:       return "VAR_STRING";
-                               case MySqlDbType.String:                return "STRING";
-                       }
-                       return "Unknown typeid";
-               }
-
-
-               public Type GetFieldType() 
-               {
-                       switch (colType) 
-                       {
-                               case MySqlDbType.Byte:          return IsUnsigned() ? typeof(System.Byte) : typeof(System.SByte);
-
-                               case MySqlDbType.Short:         return IsUnsigned() ? typeof(System.UInt16) : typeof(System.Int16);
-
-                               case MySqlDbType.Int:
-                               case MySqlDbType.Int24:         return IsUnsigned() ? typeof(System.UInt32) : typeof(System.Int32);
-
-                               case MySqlDbType.BigInt:        return IsUnsigned() ? typeof(System.UInt64) : typeof(System.Int64);
-
-                               case MySqlDbType.Float:         return typeof(System.Single);
-                               case MySqlDbType.Double:                return typeof(System.Double);
-
-                               case MySqlDbType.Time:          return typeof(System.TimeSpan);
-
-                               case MySqlDbType.Date:
-                               case MySqlDbType.Datetime:
-                               case MySqlDbType.Timestamp:     return typeof(System.DateTime);
-
-                               case MySqlDbType.Decimal:       return typeof(System.Decimal);
-
-                               case MySqlDbType.VarChar:       
-                               case MySqlDbType.String:                return typeof(System.String);
-
-                               case MySqlDbType.TinyBlob:
-                               case MySqlDbType.MediumBlob:
-                               case MySqlDbType.LongBlob:
-                               case MySqlDbType.Blob:          return typeof(System.Array);
-
-                               default:
-                               case MySqlDbType.Null:          return typeof(System.DBNull);
-                       }
-               }
-
-               public MySqlDbType GetMySqlDbType()
-               {
-                       return colType;
-               }
-
-               public DbType GetDbType() 
-               {
-                       switch (colType) 
-                       {
-                               case MySqlDbType.Decimal:               return DbType.Decimal;
-                               case MySqlDbType.Byte:                  return DbType.Byte;
-                               case MySqlDbType.Short:                 
-                                       if (IsUnsigned())
-                                               return DbType.UInt16;
-                                       else
-                                               return DbType.Int16;
-
-                               case MySqlDbType.Int:                   
-                                       if (IsUnsigned())
-                                               return DbType.UInt32;
-                                       else
-                                               return DbType.Int32;
-
-                               case MySqlDbType.Float:                 return DbType.Single;
-                               case MySqlDbType.Double:                return DbType.Double;
-                               case MySqlDbType.Null:                  return DbType.Object;
-
-                               case MySqlDbType.BigInt:                
-                                       if (IsUnsigned())
-                                               return DbType.UInt64;
-                                       else
-                                               return DbType.Int64;
-
-                               case MySqlDbType.Int24:                 
-                                       if (IsUnsigned())
-                                               return DbType.UInt32;
-                                       else
-                                               return DbType.Int32;
-                               case MySqlDbType.Date:                  
-                               case MySqlDbType.Year:
-                               case MySqlDbType.Newdate:
-                                       return DbType.Date;
-
-                               case MySqlDbType.Time:                  
-                                       return DbType.Time;
-                               case MySqlDbType.Datetime:              
-                               case MySqlDbType.Timestamp:
-                                       return DbType.DateTime;
-
-                               case MySqlDbType.Enum:                  return DbType.UInt32;
-                               case MySqlDbType.Set:                   return DbType.Object;
-
-                               case MySqlDbType.TinyBlob:              
-                               case MySqlDbType.MediumBlob:
-                               case MySqlDbType.LongBlob:
-                               case MySqlDbType.Blob:
-                                       if (IsBinary()) return DbType.Binary;
-                                       return DbType.String;
-                               case MySqlDbType.VarChar:
-                                       return DbType.String;
-                               case MySqlDbType.String:
-                                       return DbType.StringFixedLength;
-                       }
-                       throw new Exception("unknown MySqlDbType");
-               }
-
-       }
-
-}
+// ByteFX.Data data access components for .Net\r
+// Copyright (C) 2002-2003  ByteFX, Inc.\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License, or (at your option) any later version.\r
+// \r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+// Lesser General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+\r
+using System;\r
+using System.Data;\r
+using System.Data.SqlTypes;\r
+using System.Globalization;\r
+using System.Text;\r
+using ByteFX.Data.Common;\r
+\r
+namespace ByteFX.Data.MySqlClient\r
+{\r
+       internal enum ColumnFlags : int\r
+       {\r
+               NOT_NULL                = 1,\r
+               PRIMARY_KEY             = 2,\r
+               UNIQUE_KEY              = 4,\r
+               MULTIPLE_KEY    = 8,\r
+               BLOB                    = 16,\r
+               UNSIGNED                = 32,\r
+               ZERO_FILL               = 64,\r
+               BINARY                  = 128,\r
+               ENUM                    = 256,\r
+               AUTO_INCREMENT  = 512,\r
+               TIMESTAMP               = 1024,\r
+               SET                             = 2048,\r
+               NUMBER                  = 32768\r
+       };\r
+       \r
+       /// <summary>\r
+       /// Summary description for Field.\r
+       /// </summary>\r
+       internal class MySqlField : Common.Field\r
+       {\r
+               protected       MySqlDbType     colType;\r
+               protected       ColumnFlags     colFlags;\r
+               protected       int                     colDecimals;\r
+               protected       Encoding        encoding;\r
+               private static NumberFormatInfo         numberFormat = null;\r
+\r
+               protected       byte[]          buffer;\r
+               protected       long            bufIndex;\r
+               protected       long            bufLength;\r
+\r
+               public MySqlField(Encoding encoding)\r
+               {\r
+                       this.encoding = encoding;\r
+                       if (numberFormat == null)\r
+                       {\r
+                               numberFormat = (NumberFormatInfo)NumberFormatInfo.InvariantInfo.Clone();\r
+                               numberFormat.NumberDecimalSeparator = ".";\r
+                       }\r
+               }\r
+\r
+               public byte[] Buffer \r
+               {\r
+                       get { return buffer; }\r
+               }\r
+\r
+               public long     BufferIndex \r
+               {\r
+                       get { return bufIndex; }\r
+               }\r
+\r
+               public long BufferLength \r
+               {\r
+                       get { return bufLength; }\r
+               }\r
+\r
+               /// <summary>\r
+               /// CopyBuffer makes a copy of the byte buffer given to us while\r
+               /// the rowset was being read\r
+               /// </summary>\r
+               private void CopyBuffer()\r
+               {\r
+                       byte[] newbuf = new byte[ bufLength ];\r
+                       long oldIndex = bufIndex;\r
+                       for (long i=0; i < bufLength; i++)\r
+                               newbuf[i] = buffer[ oldIndex++ ];\r
+                       bufIndex = 0;\r
+                       buffer = newbuf;\r
+                       value = newbuf;\r
+               }\r
+\r
+               /// <summary>\r
+               /// GetValue returns an object that represents the value of this field.\r
+               /// </summary>\r
+               /// <returns></returns>\r
+               public object GetValue() \r
+               {\r
+                       // if our value is a byte buffer and we are using only \r
+                       // a part of that buffer, then we need to make a copy\r
+                       if (value is byte[] && (bufIndex > 0 || bufLength < buffer.Length))\r
+                               CopyBuffer();\r
+                       return value;\r
+               }\r
+\r
+               public MySqlDbType      Type \r
+               {\r
+                       get { return colType; }\r
+                       set { colType = value; }\r
+               }\r
+\r
+               public int NumericPrecision\r
+               {\r
+                       get \r
+                       {\r
+                               if (colType == MySqlDbType.Decimal)\r
+                                       return colLen;\r
+                               return -1;\r
+                       }\r
+\r
+               }\r
+\r
+               public int NumericScale\r
+               {\r
+                       get \r
+                       {\r
+                               if (colType == MySqlDbType.Decimal)\r
+                                       return colDecimals;\r
+                               return -1;\r
+                       }\r
+                       set \r
+                       {\r
+                               colDecimals = value;\r
+                       }\r
+               }\r
+\r
+               public ColumnFlags Flags \r
+               { \r
+                       get { return colFlags; }\r
+                       set { colFlags = value; }\r
+               }\r
+\r
+               public bool IsAutoIncrement()\r
+               {\r
+                       return (colFlags & ColumnFlags.AUTO_INCREMENT) > 0;\r
+               }\r
+\r
+               public bool IsNumeric()\r
+               {\r
+                       return (colFlags & ColumnFlags.NUMBER) > 0;\r
+               }\r
+\r
+               public bool AllowsNull()\r
+               {\r
+                       return (colFlags & ColumnFlags.NOT_NULL) == 0;\r
+               }\r
+\r
+               public bool IsUnique()\r
+               {\r
+                       return (colFlags & ColumnFlags.UNIQUE_KEY) > 0;\r
+               }\r
+\r
+               public bool IsPrimaryKey()\r
+               {\r
+                       return (colFlags & ColumnFlags.PRIMARY_KEY) > 0;\r
+               }\r
+\r
+               public bool IsBlob() \r
+               {\r
+                       return (colFlags & ColumnFlags.BLOB) > 0;\r
+               }\r
+\r
+               public bool IsBinary()\r
+               {\r
+                       return (colFlags & ColumnFlags.BINARY) > 0;\r
+               }\r
+\r
+               public bool IsUnsigned()\r
+               {\r
+                       return (colFlags & ColumnFlags.UNSIGNED) > 0;\r
+               }\r
+\r
+               public void SetValueData( byte[] buf, long index, long len, DBVersion version )\r
+               {\r
+                       if (len == -1)\r
+                       {\r
+                               value = DBNull.Value;\r
+                               buffer = null;\r
+                               return;\r
+                       }\r
+\r
+                       buffer = buf;\r
+                       bufIndex = index;\r
+                       bufLength = len;\r
+\r
+                       // if it is a blob and binary, then GetBytes is the way to go\r
+                       if ( IsBlob() && IsBinary() ) \r
+                       {\r
+                               dbType = DbType.Binary;\r
+                               value = buffer;\r
+                               return;\r
+                       }\r
+\r
+                       string sValue = encoding.GetString( buf, (int)index, (int)len );\r
+\r
+                       switch(colType)\r
+                       {\r
+                               case MySqlDbType.Byte:\r
+                                       if (IsUnsigned())\r
+                                               value = Byte.Parse( sValue );\r
+                                       else\r
+                                               value = SByte.Parse( sValue );\r
+                                       break;\r
+\r
+                               case MySqlDbType.Short:\r
+                                       if (IsUnsigned())\r
+                                               value = UInt16.Parse( sValue );\r
+                                       else\r
+                                               value = Int16.Parse( sValue );\r
+                                       break;\r
+                                       \r
+                               case MySqlDbType.Int : \r
+                               case MySqlDbType.Int24:\r
+                                       if (IsUnsigned())\r
+                                               value = UInt32.Parse( sValue );\r
+                                       else\r
+                                               value = Int32.Parse( sValue );\r
+                                       break;\r
+\r
+                               case MySqlDbType.BigInt:\r
+                                       if (IsUnsigned())\r
+                                               value = UInt64.Parse( sValue );\r
+                                       else\r
+                                               value = Int64.Parse( sValue );\r
+                                       break;\r
+\r
+                               case MySqlDbType.Decimal:\r
+                                       value = Decimal.Parse( sValue , numberFormat );\r
+                                       break;\r
+\r
+                               case MySqlDbType.Float:\r
+                                       value = Convert.ToSingle( sValue, numberFormat );\r
+                                       break;\r
+\r
+                               case MySqlDbType.Double:\r
+                                       value = Convert.ToDouble( sValue, numberFormat );\r
+                                       break;\r
+\r
+                               case MySqlDbType.Year:\r
+                                       value = Int32.Parse( sValue );\r
+                                       break;\r
+\r
+                               case MySqlDbType.Date:\r
+                                       ParseDateValue( "0000-00-00", "yyyy-MM-dd", sValue );\r
+                                       break;\r
+\r
+                               case MySqlDbType.Datetime:\r
+                                       ParseDateValue( "0000-00-00 00:00:00", "yyyy-MM-dd HH:mm:ss", sValue );\r
+                                       break;\r
+\r
+                               case MySqlDbType.Time:\r
+                                       if (sValue.Equals("00:00:00"))\r
+                                               value = DBNull.Value;\r
+                                       else\r
+                                               value = TimeSpan.Parse(sValue);\r
+                                       break;\r
+\r
+                               case MySqlDbType.Timestamp:\r
+                                       // MySql 4.1.0 and later use DateTime format for timestamp\r
+                                       if (version.isAtLeast(4,1,0))  \r
+                                       {\r
+                                               ParseDateValue( "0000-00-00 00:00:00", "yyyy-MM-dd HH:mm:ss", sValue );\r
+                                               return;\r
+                                       }\r
+\r
+                                       string pattern;\r
+                                       string null_value = "00000000000000";\r
+                                       switch (ColumnLength) \r
+                                       {\r
+                                               case 2:  pattern = "yy"; break;\r
+                                               case 4:  pattern = "yyMM"; break;\r
+                                               case 6:  pattern = "yyMMdd"; break;\r
+                                               case 8:  pattern = "yyyyMMdd"; break;\r
+                                               case 10: pattern = "yyMMddHHmm"; break;\r
+                                               case 12: pattern = "yyMMddHHmmss"; break;\r
+                                               case 14: \r
+                                               default: pattern = "yyyyMMddHHmmss"; break;\r
+                                       }\r
+\r
+                                       if (ColumnLength > 2 && sValue.Equals( null_value.Substring(0, ColumnLength)))\r
+                                               value = DBNull.Value;\r
+                                       else\r
+                                               value = DateTime.ParseExact( sValue, pattern, new System.Globalization.DateTimeFormatInfo());\r
+                                       break;\r
+\r
+                               case MySqlDbType.String:\r
+                               case MySqlDbType.VarChar:\r
+                               case MySqlDbType.Blob:\r
+                               case MySqlDbType.TinyBlob:\r
+                               case MySqlDbType.LongBlob:\r
+                               case MySqlDbType.MediumBlob: \r
+                                       value = sValue;\r
+                                       break;\r
+\r
+                               default:\r
+                                       throw new NotSupportedException();\r
+                       }\r
+               }\r
+\r
+               protected void ParseDateValue( string nullpattern, string pattern, string data )\r
+               {\r
+                       if ( data.Equals (nullpattern) )\r
+                               value = DBNull.Value;\r
+                       else\r
+                               value = DateTime.ParseExact( data, pattern, new System.Globalization.DateTimeFormatInfo());\r
+               }\r
+\r
+               public string GetFieldTypeName() \r
+               {\r
+                       switch (colType) \r
+                       {\r
+                               case MySqlDbType.Decimal:               return "DECIMAL";\r
+                               case MySqlDbType.Byte:                  return "TINY";\r
+                               case MySqlDbType.Short:                 return "SHORT";\r
+                               case MySqlDbType.Int:                   return "INTEGER";\r
+                               case MySqlDbType.Float:                 return "FLOAT";\r
+                               case MySqlDbType.Double:                return "DOUBLE";\r
+                               case MySqlDbType.Null:                  return "NULL";\r
+                               case MySqlDbType.Timestamp:             return "TIMESTAMP";\r
+                               case MySqlDbType.BigInt:                return "BIGINT";\r
+                               case MySqlDbType.Int24:                 return "INT24";\r
+                               case MySqlDbType.Date:                  return "DATE";\r
+                               case MySqlDbType.Time:                  return "TIME";\r
+                               case MySqlDbType.Datetime:              return "DATETIME";\r
+                               case MySqlDbType.Year:                  return "YEAR";\r
+                               case MySqlDbType.Newdate:               return "NEWDATE";\r
+                               case MySqlDbType.Enum:                  return "ENUM";\r
+                               case MySqlDbType.Set:                   return "SET";\r
+                               case MySqlDbType.TinyBlob:              return "TINY_BLOB";\r
+                               case MySqlDbType.MediumBlob:    return "MEDIUM_BLOB";\r
+                               case MySqlDbType.LongBlob:              return "LONG_BLOB";\r
+                               case MySqlDbType.Blob:                  return "BLOB";\r
+                               case MySqlDbType.VarChar:       return "VAR_STRING";\r
+                               case MySqlDbType.String:                return "STRING";\r
+                       }\r
+                       return "Unknown typeid";\r
+               }\r
+\r
+\r
+               public Type GetFieldType() \r
+               {\r
+                       switch (colType) \r
+                       {\r
+                               case MySqlDbType.Byte:          return IsUnsigned() ? typeof(System.Byte) : typeof(System.SByte);\r
+\r
+                               case MySqlDbType.Short:         return IsUnsigned() ? typeof(System.UInt16) : typeof(System.Int16);\r
+\r
+                               case MySqlDbType.Int:\r
+                               case MySqlDbType.Int24:         return IsUnsigned() ? typeof(System.UInt32) : typeof(System.Int32);\r
+\r
+                               case MySqlDbType.BigInt:        return IsUnsigned() ? typeof(System.UInt64) : typeof(System.Int64);\r
+\r
+                               case MySqlDbType.Float:         return typeof(System.Single);\r
+                               case MySqlDbType.Double:                return typeof(System.Double);\r
+\r
+                               case MySqlDbType.Time:          return typeof(System.TimeSpan);\r
+\r
+                               case MySqlDbType.Date:\r
+                               case MySqlDbType.Datetime:\r
+                               case MySqlDbType.Timestamp:     return typeof(System.DateTime);\r
+\r
+                               case MySqlDbType.Decimal:       return typeof(System.Decimal);\r
+\r
+                               case MySqlDbType.VarChar:       \r
+                               case MySqlDbType.String:                return typeof(System.String);\r
+\r
+                               case MySqlDbType.TinyBlob:\r
+                               case MySqlDbType.MediumBlob:\r
+                               case MySqlDbType.LongBlob:\r
+                               case MySqlDbType.Blob:          \r
+                                       if ((colFlags & ColumnFlags.BINARY) != 0)\r
+                                               return typeof(System.Array);\r
+                                       else\r
+                                               return typeof(System.String);\r
+\r
+                               case MySqlDbType.Year:\r
+                                       return typeof(System.Int32);\r
+\r
+                               default:\r
+                               case MySqlDbType.Null:          return typeof(System.DBNull);\r
+                       }\r
+               }\r
+\r
+               public DbType GetDbType() \r
+               {\r
+                       switch (colType) \r
+                       {\r
+                               case MySqlDbType.Decimal:               return DbType.Decimal;\r
+                               case MySqlDbType.Byte:                  return DbType.Byte;\r
+                               case MySqlDbType.Short:                 \r
+                                       if (IsUnsigned())\r
+                                               return DbType.UInt16;\r
+                                       else\r
+                                               return DbType.Int16;\r
+\r
+                               case MySqlDbType.Int:                   \r
+                                       if (IsUnsigned())\r
+                                               return DbType.UInt32;\r
+                                       else\r
+                                               return DbType.Int32;\r
+\r
+                               case MySqlDbType.Float:                 return DbType.Single;\r
+                               case MySqlDbType.Double:                return DbType.Double;\r
+                               case MySqlDbType.Null:                  return DbType.Object;\r
+\r
+                               case MySqlDbType.BigInt:                \r
+                                       if (IsUnsigned())\r
+                                               return DbType.UInt64;\r
+                                       else\r
+                                               return DbType.Int64;\r
+\r
+                               case MySqlDbType.Int24:                 \r
+                                       if (IsUnsigned())\r
+                                               return DbType.UInt32;\r
+                                       else\r
+                                               return DbType.Int32;\r
+                               case MySqlDbType.Date:                  \r
+                               case MySqlDbType.Year:\r
+                               case MySqlDbType.Newdate:\r
+                                       return DbType.Date;\r
+\r
+                               case MySqlDbType.Time:                  \r
+                                       return DbType.Time;\r
+                               case MySqlDbType.Datetime:              \r
+                               case MySqlDbType.Timestamp:\r
+                                       return DbType.DateTime;\r
+\r
+                               case MySqlDbType.Enum:                  return DbType.UInt32;\r
+                               case MySqlDbType.Set:                   return DbType.Object;\r
+\r
+                               case MySqlDbType.TinyBlob:              \r
+                               case MySqlDbType.MediumBlob:\r
+                               case MySqlDbType.LongBlob:\r
+                               case MySqlDbType.Blob:\r
+                                       if (IsBinary()) return DbType.Binary;\r
+                                       return DbType.String;\r
+                               case MySqlDbType.VarChar:\r
+                                       return DbType.String;\r
+                               case MySqlDbType.String:\r
+                                       return DbType.StringFixedLength;\r
+                       }\r
+                       throw new Exception("unknown MySqlDbType");\r
+               }\r
+\r
+       }\r
+\r
+}\r
diff --git a/mcs/class/ByteFX.Data/mysqlclient/MySqlError.cs b/mcs/class/ByteFX.Data/mysqlclient/MySqlError.cs
new file mode 100644 (file)
index 0000000..aef6410
--- /dev/null
@@ -0,0 +1,250 @@
+using System;\r
+\r
+namespace ByteFX.Data.MySqlClient\r
+{\r
+       public class MySqlError\r
+       {\r
+/*             ER_HASHCHK=1000,\r
+               ER_NISAMCHK=1001,\r
+               ER_NO=1002,\r
+               ER_YES 1003\r
+               ER_CANT_CREATE_FILE 1004\r
+               ER_CANT_CREATE_TABLE 1005\r
+               ER_CANT_CREATE_DB 1006\r
+               ER_DB_CREATE_EXISTS 1007\r
+               ER_DB_DROP_EXISTS 1008\r
+               ER_DB_DROP_DELETE 1009\r
+               ER_DB_DROP_RMDIR 1010\r
+               ER_CANT_DELETE_FILE 1011\r
+               ER_CANT_FIND_SYSTEM_REC 1012\r
+               ER_CANT_GET_STAT 1013\r
+               ER_CANT_GET_WD 1014\r
+               ER_CANT_LOCK 1015\r
+               ER_CANT_OPEN_FILE 1016\r
+               ER_FILE_NOT_FOUND 1017\r
+               ER_CANT_READ_DIR 1018\r
+               ER_CANT_SET_WD 1019\r
+               ER_CHECKREAD 1020\r
+               ER_DISK_FULL 1021\r
+               */\r
+               public static int DuplicateKey = 1022;\r
+/*             ER_ERROR_ON_CLOSE 1023\r
+               ER_ERROR_ON_READ 1024\r
+               ER_ERROR_ON_RENAME 1025\r
+               ER_ERROR_ON_WRITE 1026\r
+               ER_FILE_USED 1027\r
+               ER_FILSORT_ABORT 1028\r
+               ER_FORM_NOT_FOUND 1029\r
+               ER_GET_ERRNO 1030\r
+               ER_ILLEGAL_HA 1031*/\r
+               public static int KeyNotFound = 1032;\r
+/*             ER_NOT_FORM_FILE 1033\r
+               ER_NOT_KEYFILE 1034\r
+               ER_OLD_KEYFILE 1035\r
+               ER_OPEN_AS_READONLY 1036\r
+               ER_OUTOFMEMORY 1037\r
+               ER_OUT_OF_SORTMEMORY 1038\r
+               ER_UNEXPECTED_EOF 1039\r
+               ER_CON_COUNT_ERROR 1040\r
+               ER_OUT_OF_RESOURCES 1041\r
+               ER_BAD_HOST_ERROR 1042\r
+               ER_HANDSHAKE_ERROR 1043\r
+               ER_DBACCESS_DENIED_ERROR 1044\r
+               ER_ACCESS_DENIED_ERROR 1045\r
+               ER_NO_DB_ERROR 1046\r
+               ER_UNKNOWN_COM_ERROR 1047\r
+               ER_BAD_NULL_ERROR 1048\r
+               ER_BAD_DB_ERROR 1049\r
+               ER_TABLE_EXISTS_ERROR 1050\r
+               ER_BAD_TABLE_ERROR 1051\r
+               ER_NON_UNIQ_ERROR 1052\r
+               ER_SERVER_SHUTDOWN 1053\r
+               ER_BAD_FIELD_ERROR 1054\r
+               ER_WRONG_FIELD_WITH_GROUP 1055\r
+               ER_WRONG_GROUP_FIELD 1056\r
+               ER_WRONG_SUM_SELECT 1057\r
+               ER_WRONG_VALUE_COUNT 1058\r
+               ER_TOO_LONG_IDENT 1059\r
+               ER_DUP_FIELDNAME 1060*/\r
+               public static int DuplicateKeyName = 1061;\r
+               public static int DuplicateKeyEntry = 1062;\r
+               /*              ER_WRONG_FIELD_SPEC 1063\r
+               ER_PARSE_ERROR 1064\r
+               ER_EMPTY_QUERY 1065\r
+               ER_NONUNIQ_TABLE 1066\r
+               ER_INVALID_DEFAULT 1067\r
+               ER_MULTIPLE_PRI_KEY 1068\r
+               ER_TOO_MANY_KEYS 1069\r
+               ER_TOO_MANY_KEY_PARTS 1070\r
+               ER_TOO_LONG_KEY 1071\r
+               ER_KEY_COLUMN_DOES_NOT_EXITS 1072\r
+               ER_BLOB_USED_AS_KEY 1073\r
+               ER_TOO_BIG_FIELDLENGTH 1074\r
+               ER_WRONG_AUTO_KEY 1075\r
+               ER_READY 1076\r
+               ER_NORMAL_SHUTDOWN 1077\r
+               ER_GOT_SIGNAL 1078\r
+               ER_SHUTDOWN_COMPLETE 1079\r
+               ER_FORCING_CLOSE 1080\r
+               ER_IPSOCK_ERROR 1081\r
+               ER_NO_SUCH_INDEX 1082\r
+               ER_WRONG_FIELD_TERMINATORS 1083\r
+               ER_BLOBS_AND_NO_TERMINATED 1084\r
+               ER_TEXTFILE_NOT_READABLE 1085\r
+               ER_FILE_EXISTS_ERROR 1086\r
+               ER_LOAD_INFO 1087\r
+               ER_ALTER_INFO 1088\r
+               ER_WRONG_SUB_KEY 1089\r
+               ER_CANT_REMOVE_ALL_FIELDS 1090\r
+               ER_CANT_DROP_FIELD_OR_KEY 1091\r
+               ER_INSERT_INFO 1092\r
+               ER_INSERT_TABLE_USED 1093\r
+               ER_NO_SUCH_THREAD 1094\r
+               ER_KILL_DENIED_ERROR 1095\r
+               ER_NO_TABLES_USED 1096\r
+               ER_TOO_BIG_SET 1097\r
+               ER_NO_UNIQUE_LOGFILE 1098\r
+               ER_TABLE_NOT_LOCKED_FOR_WRITE 1099\r
+               ER_TABLE_NOT_LOCKED 1100\r
+               ER_BLOB_CANT_HAVE_DEFAULT 1101\r
+               ER_WRONG_DB_NAME 1102\r
+               ER_WRONG_TABLE_NAME 1103\r
+               ER_TOO_BIG_SELECT 1104\r
+               ER_UNKNOWN_ERROR 1105\r
+               ER_UNKNOWN_PROCEDURE 1106\r
+               ER_WRONG_PARAMCOUNT_TO_PROCEDURE 1107\r
+               ER_WRONG_PARAMETERS_TO_PROCEDURE 1108\r
+               ER_UNKNOWN_TABLE 1109\r
+               ER_FIELD_SPECIFIED_TWICE 1110\r
+               ER_INVALID_GROUP_FUNC_USE 1111\r
+               ER_UNSUPPORTED_EXTENSION 1112\r
+               ER_TABLE_MUST_HAVE_COLUMNS 1113\r
+               ER_RECORD_FILE_FULL 1114\r
+               ER_UNKNOWN_CHARACTER_SET 1115\r
+               ER_TOO_MANY_TABLES 1116\r
+               ER_TOO_MANY_FIELDS 1117\r
+               ER_TOO_BIG_ROWSIZE 1118\r
+               ER_STACK_OVERRUN 1119\r
+               ER_WRONG_OUTER_JOIN 1120\r
+               ER_NULL_COLUMN_IN_INDEX 1121\r
+               ER_CANT_FIND_UDF 1122\r
+               ER_CANT_INITIALIZE_UDF 1123\r
+               ER_UDF_NO_PATHS 1124\r
+               ER_UDF_EXISTS 1125\r
+               ER_CANT_OPEN_LIBRARY 1126\r
+               ER_CANT_FIND_DL_ENTRY 1127\r
+               ER_FUNCTION_NOT_DEFINED 1128\r
+               ER_HOST_IS_BLOCKED 1129\r
+               */\r
+               public static int HostNotPrivileged = 1130;\r
+               public static int AnonymousUser = 1131;\r
+               public static int PasswordNotAllowed = 1132;\r
+               public static int PasswordNoMatch = 1133;\r
+/*             ER_UPDATE_INFO 1134\r
+               ER_CANT_CREATE_THREAD 1135\r
+               ER_WRONG_VALUE_COUNT_ON_ROW 1136\r
+               ER_CANT_REOPEN_TABLE 1137\r
+               ER_INVALID_USE_OF_NULL 1138\r
+               ER_REGEXP_ERROR 1139\r
+               ER_MIX_OF_GROUP_FUNC_AND_FIELDS 1140\r
+               ER_NONEXISTING_GRANT 1141\r
+               ER_TABLEACCESS_DENIED_ERROR 1142\r
+               ER_COLUMNACCESS_DENIED_ERROR 1143\r
+               ER_ILLEGAL_GRANT_FOR_TABLE 1144\r
+               ER_GRANT_WRONG_HOST_OR_USER 1145\r
+               ER_NO_SUCH_TABLE 1146\r
+               ER_NONEXISTING_TABLE_GRANT 1147\r
+               ER_NOT_ALLOWED_COMMAND 1148\r
+               ER_SYNTAX_ERROR 1149\r
+               ER_DELAYED_CANT_CHANGE_LOCK 1150\r
+               ER_TOO_MANY_DELAYED_THREADS 1151\r
+               ER_ABORTING_CONNECTION 1152\r
+               ER_NET_PACKET_TOO_LARGE 1153\r
+               ER_NET_READ_ERROR_FROM_PIPE 1154\r
+               ER_NET_FCNTL_ERROR 1155\r
+               ER_NET_PACKETS_OUT_OF_ORDER 1156\r
+               ER_NET_UNCOMPRESS_ERROR 1157\r
+               ER_NET_READ_ERROR 1158\r
+               ER_NET_READ_INTERRUPTED 1159\r
+               ER_NET_ERROR_ON_WRITE 1160\r
+               ER_NET_WRITE_INTERRUPTED 1161\r
+               ER_TOO_LONG_STRING 1162\r
+               ER_TABLE_CANT_HANDLE_BLOB 1163\r
+               ER_TABLE_CANT_HANDLE_AUTO_INCREMENT 1164\r
+               ER_DELAYED_INSERT_TABLE_LOCKED 1165\r
+               ER_WRONG_COLUMN_NAME 1166\r
+               ER_WRONG_KEY_COLUMN 1167\r
+               ER_WRONG_MRG_TABLE 1168\r
+               ER_DUP_UNIQUE 1169\r
+               ER_BLOB_KEY_WITHOUT_LENGTH 1170\r
+               ER_PRIMARY_CANT_HAVE_NULL 1171\r
+               ER_TOO_MANY_ROWS 1172\r
+               ER_REQUIRES_PRIMARY_KEY 1173\r
+               ER_NO_RAID_COMPILED 1174\r
+               ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE 1175\r
+               ER_KEY_DOES_NOT_EXITS 1176\r
+               ER_CHECK_NO_SUCH_TABLE 1177\r
+               ER_CHECK_NOT_IMPLEMENTED 1178\r
+               ER_CANT_DO_THIS_DURING_AN_TRANSACTION 1179\r
+               ER_ERROR_DURING_COMMIT 1180\r
+               ER_ERROR_DURING_ROLLBACK 1181\r
+               ER_ERROR_DURING_FLUSH_LOGS 1182\r
+               ER_ERROR_DURING_CHECKPOINT 1183\r
+               ER_NEW_ABORTING_CONNECTION 1184\r
+               ER_DUMP_NOT_IMPLEMENTED    1185\r
+               ER_FLUSH_MASTER_BINLOG_CLOSED 1186\r
+               ER_INDEX_REBUILD  1187\r
+               ER_MASTER 1188\r
+               ER_MASTER_NET_READ 1189\r
+               ER_MASTER_NET_WRITE 1190\r
+               ER_FT_MATCHING_KEY_NOT_FOUND 1191\r
+               ER_LOCK_OR_ACTIVE_TRANSACTION 1192\r
+               ER_UNKNOWN_SYSTEM_VARIABLE 1193\r
+               ER_CRASHED_ON_USAGE 1194\r
+               ER_CRASHED_ON_REPAIR 1195\r
+               ER_WARNING_NOT_COMPLETE_ROLLBACK 1196\r
+               ER_TRANS_CACHE_FULL 1197\r
+               ER_SLAVE_MUST_STOP 1198\r
+               ER_SLAVE_NOT_RUNNING 1199\r
+               ER_BAD_SLAVE 1200\r
+               ER_MASTER_INFO 1201\r
+               ER_SLAVE_THREAD 1202\r
+               ER_TOO_MANY_USER_CONNECTIONS 1203\r
+               ER_SET_CONSTANTS_ONLY 1204\r
+               ER_LOCK_WAIT_TIMEOUT 1205\r
+               ER_LOCK_TABLE_FULL 1206\r
+               ER_READ_ONLY_TRANSACTION 1207\r
+               ER_DROP_DB_WITH_READ_LOCK 1208\r
+               ER_CREATE_DB_WITH_READ_LOCK 1209\r
+               ER_WRONG_ARGUMENTS 1210\r
+               ER_NO_PERMISSION_TO_CREATE_USER 1211\r
+               ER_UNION_TABLES_IN_DIFFERENT_DIR 1212\r
+               ER_LOCK_DEADLOCK 1213\r
+               ER_TABLE_CANT_HANDLE_FULLTEXT 1214\r
+               ER_CANNOT_ADD_FOREIGN 1215\r
+               ER_NO_REFERENCED_ROW 1216\r
+               ER_ROW_IS_REFERENCED 1217\r
+               ER_CONNECT_TO_MASTER 1218\r
+               ER_QUERY_ON_MASTER 1219\r
+               ER_ERROR_WHEN_EXECUTING_COMMAND 1220\r
+               ER_WRONG_USAGE 1221\r
+               ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT 1222\r
+               ER_CANT_UPDATE_WITH_READLOCK 1223\r
+               ER_MIXING_NOT_ALLOWED 1224\r
+               ER_DUP_ARGUMENT 1225\r
+               ER_USER_LIMIT_REACHED 1226\r
+               ER_SPECIFIC_ACCESS_DENIED_ERROR 1227\r
+               ER_LOCAL_VARIABLE 1228\r
+               ER_GLOBAL_VARIABLE 1229\r
+               ER_NO_DEFAULT 1230\r
+               ER_WRONG_VALUE_FOR_VAR 1231\r
+               ER_WRONG_TYPE_FOR_VAR 1232\r
+               ER_VAR_CANT_BE_READ 1233\r
+               ER_CANT_USE_OPTION_HERE 1234\r
+               ER_NOT_SUPPORTED_YET    1235\r
+               ER_MASTER_FATAL_ERROR_READING_BINLOG 1236\r
+               ER_SLAVE_IGNORED_TABLE 1237 // only the slave SQL thread can be sent this \r
+               ER_ERROR_MESSAGES 238*/\r
+\r
+       };\r
+}\r
index c2b710821a3a570b76f7ddba2f842c4739fd282d..d023a6e692a8aaa12c236816f7ea364e2f29711b 100644 (file)
-using System;
-using System.Data;
-using ByteFX.Data.MySqlClient;
-
-namespace ByteFX.Data.MySqlClient
-{
-       /// <summary>
-       /// Helper class that makes it easier to work with the provider.
-       /// </summary>
-       public sealed class MySqlHelper
-       {
-               // this class provides only static methods
-               private MySqlHelper()
-               {
-               }
-
-               #region ExecuteNonQuery
-
-               /// <summary>
-               /// Executes a single command against a MySQL database.  The <see cref="MySqlConnection"/> is assumed to be
-               /// open when the method is called and remains open after the method completes.
-               /// </summary>
-               /// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
-               /// <param name="commandText">SQL command to be executed</param>
-               /// <param name="commandParameters">Array of <see cref="MySqlParameter"/> objects to use with the command.</param>
-               /// <returns></returns>
-               public static int ExecuteNonQuery( MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters )
-               {
-                       //create a command and prepare it for execution
-                       MySqlCommand cmd = new MySqlCommand();
-                       cmd.Connection = connection;
-                       cmd.CommandText = commandText;
-                       cmd.CommandType = CommandType.Text;
-
-                       if (commandParameters != null)
-                               foreach (MySqlParameter p in commandParameters)
-                                       cmd.Parameters.Add( p );
-
-                       int result = cmd.ExecuteNonQuery();
-                       cmd.Parameters.Clear();
-
-                       return result;
-               }
-
-               /// <summary>
-               /// Executes a single command against a MySQL database.  A new <see cref="MySqlConnection"/> is created
-               /// using the <see cref="MySqlConnection.ConnectionString"/> given.
-               /// </summary>
-               /// <param name="connectionString"><see cref="MySqlConnection.ConnectionString"/> to use</param>
-               /// <param name="commandText">SQL command to be executed</param>
-               /// <param name="parms">Array of <see cref="MySqlParameter"/> objects to use with the command.</param>
-               /// <returns></returns>
-               public static int ExecuteNonQuery( string connectionString, string commandText, params MySqlParameter[] parms )
-               {
-                       //create & open a SqlConnection, and dispose of it after we are done.
-                       using (MySqlConnection cn = new MySqlConnection(connectionString))
-                       {
-                               cn.Open();
-
-                               //call the overload that takes a connection in place of the connection string
-                               return ExecuteNonQuery(cn, commandText, parms );
-                       }
-               }
-               #endregion
-
-               #region ExecuteDataSet
-
-               /// <summary>
-               /// Executes a single SQL command and returns the first row of the resultset.  A new MySqlConnection object
-               /// is created, opened, and closed during this method.
-               /// </summary>
-               /// <param name="connectionString">Settings to be used for the connection</param>
-               /// <param name="commandText">Command to execute</param>
-               /// <param name="parms">Parameters to use for the command</param>
-               /// <returns>DataRow containing the first row of the resultset</returns>
-               public static DataRow ExecuteDatarow( string connectionString, string commandText, params MySqlParameter[] parms )
-               {
-                       DataSet ds = ExecuteDataset( connectionString, commandText, parms );
-                       if (ds == null) return null;
-                       if (ds.Tables.Count == 0) return null;
-                       if (ds.Tables[0].Rows.Count == 0) return null;
-                       return ds.Tables[0].Rows[0];
-               }
-
-               /// <summary>
-               /// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.  
-               /// A new MySqlConnection object is created, opened, and closed during this method.
-               /// </summary>
-               /// <param name="connectionString">Settings to be used for the connection</param>
-               /// <param name="commandText">Command to execute</param>
-               /// <returns><see cref="DataSet"/> containing the resultset</returns>
-               public static DataSet ExecuteDataset(string connectionString, string commandText)
-               {
-                       //pass through the call providing null for the set of SqlParameters
-                       return ExecuteDataset(connectionString, commandText, (MySqlParameter[])null);
-               }
-
-               /// <summary>
-               /// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.  
-               /// A new MySqlConnection object is created, opened, and closed during this method.
-               /// </summary>
-               /// <param name="connectionString">Settings to be used for the connection</param>
-               /// <param name="commandText">Command to execute</param>
-               /// <param name="commandParameters">Parameters to use for the command</param>
-               /// <returns><see cref="DataSet"/> containing the resultset</returns>
-               public static DataSet ExecuteDataset(string connectionString, string commandText, params MySqlParameter[] commandParameters)
-               {
-                       //create & open a SqlConnection, and dispose of it after we are done.
-                       using (MySqlConnection cn = new MySqlConnection(connectionString))
-                       {
-                               cn.Open();
-
-                               //call the overload that takes a connection in place of the connection string
-                               return ExecuteDataset(cn, commandText, commandParameters);
-                       }
-               }
-
-               /// <summary>
-               /// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.  
-               /// The state of the <see cref="MySqlConnection"/> object remains unchanged after execution
-               /// of this method.
-               /// </summary>
-               /// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
-               /// <param name="commandText">Command to execute</param>
-               /// <returns><see cref="DataSet"/> containing the resultset</returns>
-               public static DataSet ExecuteDataset(MySqlConnection connection, string commandText)
-               {
-                       //pass through the call providing null for the set of SqlParameters
-                       return ExecuteDataset(connection, commandText, (MySqlParameter[])null);
-               }
-
-               /// <summary>
-               /// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.  
-               /// The state of the <see cref="MySqlConnection"/> object remains unchanged after execution
-               /// of this method.
-               /// </summary>
-               /// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
-               /// <param name="commandText">Command to execute</param>
-               /// <param name="commandParameters">Parameters to use for the command</param>
-               /// <returns><see cref="DataSet"/> containing the resultset</returns>
-               public static DataSet ExecuteDataset(MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters)
-               {
-                       //create a command and prepare it for execution
-                       MySqlCommand cmd = new MySqlCommand();
-                       cmd.Connection = connection;
-                       cmd.CommandText = commandText;
-                       cmd.CommandType = CommandType.Text;
-
-                       if (commandParameters != null)
-                               foreach (MySqlParameter p in commandParameters)
-                                       cmd.Parameters.Add( p );
-                       
-                       //create the DataAdapter & DataSet
-                       MySqlDataAdapter da = new MySqlDataAdapter(cmd);
-                       DataSet ds = new DataSet();
-
-                       //fill the DataSet using default values for DataTable names, etc.
-                       da.Fill(ds);
-                       
-                       // detach the MySqlParameters from the command object, so they can be used again.                       
-                       cmd.Parameters.Clear();
-                       
-                       //return the dataset
-                       return ds;                                              
-               }
-
-               /// <summary>
-               /// Updates the given table with data from the given <see cref="DataSet"/>
-               /// </summary>
-               /// <param name="connectionString">Settings to use for the update</param>
-               /// <param name="commandText">Command text to use for the update</param>
-               /// <param name="ds"><see cref="DataSet"/> containing the new data to use in the update</param>
-               /// <param name="tablename">Tablename in the dataset to update</param>
-               public static void UpdateDataSet( string connectionString, string commandText, DataSet ds, string tablename )
-               {
-                       MySqlConnection cn = new MySqlConnection( connectionString );
-                       cn.Open();
-                       MySqlDataAdapter da = new MySqlDataAdapter( commandText, cn );
-                       MySqlCommandBuilder cb = new MySqlCommandBuilder( da );
-                       da.Update( ds, tablename );
-                       cn.Close();
-               }
-
-               #endregion
-
-               #region ExecuteDataReader
-
-               /// <summary>
-               /// Executes a single command against a MySQL database, possibly inside an existing transaction.
-               /// </summary>
-               /// <param name="connection"><see cref="MySqlConnection"/> object to use for the command</param>
-               /// <param name="transaction"><see cref="MySqlTransaction"/> object to use for the command</param>
-               /// <param name="commandText">Command text to use</param>
-               /// <param name="commandParameters">Array of <see cref="MySqlParameter"/> objects to use with the command</param>
-               /// <param name="ExternalConn">True if the connection should be preserved, false if not</param>
-               /// <returns><see cref="MySqlDataReader"/> object ready to read the results of the command</returns>
-               private static MySqlDataReader ExecuteReader(MySqlConnection connection, MySqlTransaction transaction, string commandText, MySqlParameter[] commandParameters, bool ExternalConn )
-               {       
-                       //create a command and prepare it for execution
-                       MySqlCommand cmd = new MySqlCommand();
-                       cmd.Connection = connection;
-                       cmd.Transaction = transaction;
-                       cmd.CommandText = commandText;
-                       cmd.CommandType = CommandType.Text;
-                       
-                       if (commandParameters != null)
-                               foreach (MySqlParameter p in commandParameters)
-                                       cmd.Parameters.Add( p );
-
-                       //create a reader
-                       MySqlDataReader dr;
-
-                       // call ExecuteReader with the appropriate CommandBehavior
-                       if (ExternalConn)
-                       {
-                               dr = cmd.ExecuteReader();
-                       }
-                       else
-                       {
-                               dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
-                       }
-                       
-                       // detach the SqlParameters from the command object, so they can be used again.
-                       cmd.Parameters.Clear();
-                       
-                       return dr;
-               }
-
-               /// <summary>
-               /// Executes a single command against a MySQL database.
-               /// </summary>
-               /// <param name="connectionString">Settings to use for this command</param>
-               /// <param name="commandText">Command text to use</param>
-               /// <returns><see cref="MySqlDataReader"/> object ready to read the results of the command</returns>
-               public static MySqlDataReader ExecuteReader(string connectionString, string commandText)
-               {
-                       //pass through the call providing null for the set of SqlParameters
-                       return ExecuteReader(connectionString, commandText, (MySqlParameter[])null);
-               }
-
-               /// <summary>
-               /// Executes a single command against a MySQL database.
-               /// </summary>
-               /// <param name="connectionString">Settings to use for this command</param>
-               /// <param name="commandText">Command text to use</param>
-               /// <param name="commandParameters">Array of <see cref="MySqlParameter"/> objects to use with the command</param>
-               /// <returns><see cref="MySqlDataReader"/> object ready to read the results of the command</returns>
-               public static MySqlDataReader ExecuteReader(string connectionString, string commandText, params MySqlParameter[] commandParameters)
-               {
-                       //create & open a SqlConnection
-                       MySqlConnection cn = new MySqlConnection(connectionString);
-                       cn.Open();
-
-                       try
-                       {
-                               //call the private overload that takes an internally owned connection in place of the connection string
-                               return ExecuteReader(cn, null, commandText, commandParameters, false );
-                       }
-                       catch
-                       {
-                               //if we fail to return the SqlDatReader, we need to close the connection ourselves
-                               cn.Close();
-                               throw;
-                       }
-               }
-               #endregion
-
-               #region ExecuteScalar
-
-               /// <summary>
-               /// Execute a single command against a MySQL database.
-               /// </summary>
-               /// <param name="connectionString">Settings to use for the update</param>
-               /// <param name="commandText">Command text to use for the update</param>
-               /// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
-               public static object ExecuteScalar(string connectionString, string commandText)
-               {
-                       //pass through the call providing null for the set of MySqlParameters
-                       return ExecuteScalar(connectionString, commandText, (MySqlParameter[])null);
-               }
-
-               /// <summary>
-               /// Execute a single command against a MySQL database.
-               /// </summary>
-               /// <param name="connectionString">Settings to use for the command</param>
-               /// <param name="commandText">Command text to use for the command</param>
-               /// <param name="commandParameters">Parameters to use for the command</param>
-               /// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
-               public static object ExecuteScalar(string connectionString, string commandText, params MySqlParameter[] commandParameters)
-               {
-                       //create & open a SqlConnection, and dispose of it after we are done.
-                       using (MySqlConnection cn = new MySqlConnection(connectionString))
-                       {
-                               cn.Open();
-
-                               //call the overload that takes a connection in place of the connection string
-                               return ExecuteScalar(cn, commandText, commandParameters);
-                       }
-               }
-
-               /// <summary>
-               /// Execute a single command against a MySQL database.
-               /// </summary>
-               /// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
-               /// <param name="commandText">Command text to use for the command</param>
-               /// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
-               public static object ExecuteScalar(MySqlConnection connection, string commandText)
-               {
-                       //pass through the call providing null for the set of MySqlParameters
-                       return ExecuteScalar(connection, commandText, (MySqlParameter[])null);
-               }
-
-               /// <summary>
-               /// Execute a single command against a MySQL database.
-               /// </summary>
-               /// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
-               /// <param name="commandText">Command text to use for the command</param>
-               /// <param name="commandParameters">Parameters to use for the command</param>
-               /// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
-               public static object ExecuteScalar(MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters)
-               {
-                       //create a command and prepare it for execution
-                       MySqlCommand cmd = new MySqlCommand();
-                       cmd.Connection = connection;
-                       cmd.CommandText = commandText;
-                       cmd.CommandType = CommandType.Text;
-                       
-                       if (commandParameters != null)
-                               foreach (MySqlParameter p in commandParameters)
-                                       cmd.Parameters.Add( p );
-                       
-                       //execute the command & return the results
-                       object retval = cmd.ExecuteScalar();
-                       
-                       // detach the SqlParameters from the command object, so they can be used again.
-                       cmd.Parameters.Clear();
-                       return retval;
-                       
-               }
-
-               #endregion
-       }
-}
+using System;\r
+using System.Data;\r
+using ByteFX.Data.MySqlClient;\r
+\r
+namespace ByteFX.Data.MySqlClient\r
+{\r
+       /// <summary>\r
+       /// Helper class that makes it easier to work with the provider.\r
+       /// </summary>\r
+       public sealed class MySqlHelper\r
+       {\r
+               // this class provides only static methods\r
+               private MySqlHelper()\r
+               {\r
+               }\r
+\r
+               #region ExecuteNonQuery\r
+\r
+               /// <summary>\r
+               /// Executes a single command against a MySQL database.  The <see cref="MySqlConnection"/> is assumed to be\r
+               /// open when the method is called and remains open after the method completes.\r
+               /// </summary>\r
+               /// <param name="connection"><see cref="MySqlConnection"/> object to use</param>\r
+               /// <param name="commandText">SQL command to be executed</param>\r
+               /// <param name="commandParameters">Array of <see cref="MySqlParameter"/> objects to use with the command.</param>\r
+               /// <returns></returns>\r
+               public static int ExecuteNonQuery( MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters )\r
+               {\r
+                       //create a command and prepare it for execution\r
+                       MySqlCommand cmd = new MySqlCommand();\r
+                       cmd.Connection = connection;\r
+                       cmd.CommandText = commandText;\r
+                       cmd.CommandType = CommandType.Text;\r
+\r
+                       if (commandParameters != null)\r
+                               foreach (MySqlParameter p in commandParameters)\r
+                                       cmd.Parameters.Add( p );\r
+\r
+                       int result = cmd.ExecuteNonQuery();\r
+                       cmd.Parameters.Clear();\r
+\r
+                       return result;\r
+               }\r
+\r
+               /// <summary>\r
+               /// Executes a single command against a MySQL database.  A new <see cref="MySqlConnection"/> is created\r
+               /// using the <see cref="MySqlConnection.ConnectionString"/> given.\r
+               /// </summary>\r
+               /// <param name="connectionString"><see cref="MySqlConnection.ConnectionString"/> to use</param>\r
+               /// <param name="commandText">SQL command to be executed</param>\r
+               /// <param name="parms">Array of <see cref="MySqlParameter"/> objects to use with the command.</param>\r
+               /// <returns></returns>\r
+               public static int ExecuteNonQuery( string connectionString, string commandText, params MySqlParameter[] parms )\r
+               {\r
+                       //create & open a SqlConnection, and dispose of it after we are done.\r
+                       using (MySqlConnection cn = new MySqlConnection(connectionString))\r
+                       {\r
+                               cn.Open();\r
+\r
+                               //call the overload that takes a connection in place of the connection string\r
+                               return ExecuteNonQuery(cn, commandText, parms );\r
+                       }\r
+               }\r
+               #endregion\r
+\r
+               #region ExecuteDataSet\r
+\r
+               /// <summary>\r
+               /// Executes a single SQL command and returns the first row of the resultset.  A new MySqlConnection object\r
+               /// is created, opened, and closed during this method.\r
+               /// </summary>\r
+               /// <param name="connectionString">Settings to be used for the connection</param>\r
+               /// <param name="commandText">Command to execute</param>\r
+               /// <param name="parms">Parameters to use for the command</param>\r
+               /// <returns>DataRow containing the first row of the resultset</returns>\r
+               public static DataRow ExecuteDatarow( string connectionString, string commandText, params MySqlParameter[] parms )\r
+               {\r
+                       DataSet ds = ExecuteDataset( connectionString, commandText, parms );\r
+                       if (ds == null) return null;\r
+                       if (ds.Tables.Count == 0) return null;\r
+                       if (ds.Tables[0].Rows.Count == 0) return null;\r
+                       return ds.Tables[0].Rows[0];\r
+               }\r
+\r
+               /// <summary>\r
+               /// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.  \r
+               /// A new MySqlConnection object is created, opened, and closed during this method.\r
+               /// </summary>\r
+               /// <param name="connectionString">Settings to be used for the connection</param>\r
+               /// <param name="commandText">Command to execute</param>\r
+               /// <returns><see cref="DataSet"/> containing the resultset</returns>\r
+               public static DataSet ExecuteDataset(string connectionString, string commandText)\r
+               {\r
+                       //pass through the call providing null for the set of SqlParameters\r
+                       return ExecuteDataset(connectionString, commandText, (MySqlParameter[])null);\r
+               }\r
+\r
+               /// <summary>\r
+               /// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.  \r
+               /// A new MySqlConnection object is created, opened, and closed during this method.\r
+               /// </summary>\r
+               /// <param name="connectionString">Settings to be used for the connection</param>\r
+               /// <param name="commandText">Command to execute</param>\r
+               /// <param name="commandParameters">Parameters to use for the command</param>\r
+               /// <returns><see cref="DataSet"/> containing the resultset</returns>\r
+               public static DataSet ExecuteDataset(string connectionString, string commandText, params MySqlParameter[] commandParameters)\r
+               {\r
+                       //create & open a SqlConnection, and dispose of it after we are done.\r
+                       using (MySqlConnection cn = new MySqlConnection(connectionString))\r
+                       {\r
+                               cn.Open();\r
+\r
+                               //call the overload that takes a connection in place of the connection string\r
+                               return ExecuteDataset(cn, commandText, commandParameters);\r
+                       }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.  \r
+               /// The state of the <see cref="MySqlConnection"/> object remains unchanged after execution\r
+               /// of this method.\r
+               /// </summary>\r
+               /// <param name="connection"><see cref="MySqlConnection"/> object to use</param>\r
+               /// <param name="commandText">Command to execute</param>\r
+               /// <returns><see cref="DataSet"/> containing the resultset</returns>\r
+               public static DataSet ExecuteDataset(MySqlConnection connection, string commandText)\r
+               {\r
+                       //pass through the call providing null for the set of SqlParameters\r
+                       return ExecuteDataset(connection, commandText, (MySqlParameter[])null);\r
+               }\r
+\r
+               /// <summary>\r
+               /// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.  \r
+               /// The state of the <see cref="MySqlConnection"/> object remains unchanged after execution\r
+               /// of this method.\r
+               /// </summary>\r
+               /// <param name="connection"><see cref="MySqlConnection"/> object to use</param>\r
+               /// <param name="commandText">Command to execute</param>\r
+               /// <param name="commandParameters">Parameters to use for the command</param>\r
+               /// <returns><see cref="DataSet"/> containing the resultset</returns>\r
+               public static DataSet ExecuteDataset(MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters)\r
+               {\r
+                       //create a command and prepare it for execution\r
+                       MySqlCommand cmd = new MySqlCommand();\r
+                       cmd.Connection = connection;\r
+                       cmd.CommandText = commandText;\r
+                       cmd.CommandType = CommandType.Text;\r
+\r
+                       if (commandParameters != null)\r
+                               foreach (MySqlParameter p in commandParameters)\r
+                                       cmd.Parameters.Add( p );\r
+                       \r
+                       //create the DataAdapter & DataSet\r
+                       MySqlDataAdapter da = new MySqlDataAdapter(cmd);\r
+                       DataSet ds = new DataSet();\r
+\r
+                       //fill the DataSet using default values for DataTable names, etc.\r
+                       da.Fill(ds);\r
+                       \r
+                       // detach the MySqlParameters from the command object, so they can be used again.                       \r
+                       cmd.Parameters.Clear();\r
+                       \r
+                       //return the dataset\r
+                       return ds;                                              \r
+               }\r
+\r
+               /// <summary>\r
+               /// Updates the given table with data from the given <see cref="DataSet"/>\r
+               /// </summary>\r
+               /// <param name="connectionString">Settings to use for the update</param>\r
+               /// <param name="commandText">Command text to use for the update</param>\r
+               /// <param name="ds"><see cref="DataSet"/> containing the new data to use in the update</param>\r
+               /// <param name="tablename">Tablename in the dataset to update</param>\r
+               public static void UpdateDataSet( string connectionString, string commandText, DataSet ds, string tablename )\r
+               {\r
+                       MySqlConnection cn = new MySqlConnection( connectionString );\r
+                       cn.Open();\r
+                       MySqlDataAdapter da = new MySqlDataAdapter( commandText, cn );\r
+                       MySqlCommandBuilder cb = new MySqlCommandBuilder( da );\r
+                       da.Update( ds, tablename );\r
+                       cn.Close();\r
+               }\r
+\r
+               #endregion\r
+\r
+               #region ExecuteDataReader\r
+\r
+               /// <summary>\r
+               /// Executes a single command against a MySQL database, possibly inside an existing transaction.\r
+               /// </summary>\r
+               /// <param name="connection"><see cref="MySqlConnection"/> object to use for the command</param>\r
+               /// <param name="transaction"><see cref="MySqlTransaction"/> object to use for the command</param>\r
+               /// <param name="commandText">Command text to use</param>\r
+               /// <param name="commandParameters">Array of <see cref="MySqlParameter"/> objects to use with the command</param>\r
+               /// <param name="ExternalConn">True if the connection should be preserved, false if not</param>\r
+               /// <returns><see cref="MySqlDataReader"/> object ready to read the results of the command</returns>\r
+               private static MySqlDataReader ExecuteReader(MySqlConnection connection, MySqlTransaction transaction, string commandText, MySqlParameter[] commandParameters, bool ExternalConn )\r
+               {       \r
+                       //create a command and prepare it for execution\r
+                       MySqlCommand cmd = new MySqlCommand();\r
+                       cmd.Connection = connection;\r
+                       cmd.Transaction = transaction;\r
+                       cmd.CommandText = commandText;\r
+                       cmd.CommandType = CommandType.Text;\r
+                       \r
+                       if (commandParameters != null)\r
+                               foreach (MySqlParameter p in commandParameters)\r
+                                       cmd.Parameters.Add( p );\r
+\r
+                       //create a reader\r
+                       MySqlDataReader dr;\r
+\r
+                       // call ExecuteReader with the appropriate CommandBehavior\r
+                       if (ExternalConn)\r
+                       {\r
+                               dr = cmd.ExecuteReader();\r
+                       }\r
+                       else\r
+                       {\r
+                               dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);\r
+                       }\r
+                       \r
+                       // detach the SqlParameters from the command object, so they can be used again.\r
+                       cmd.Parameters.Clear();\r
+                       \r
+                       return dr;\r
+               }\r
+\r
+               /// <summary>\r
+               /// Executes a single command against a MySQL database.\r
+               /// </summary>\r
+               /// <param name="connectionString">Settings to use for this command</param>\r
+               /// <param name="commandText">Command text to use</param>\r
+               /// <returns><see cref="MySqlDataReader"/> object ready to read the results of the command</returns>\r
+               public static MySqlDataReader ExecuteReader(string connectionString, string commandText)\r
+               {\r
+                       //pass through the call providing null for the set of SqlParameters\r
+                       return ExecuteReader(connectionString, commandText, (MySqlParameter[])null);\r
+               }\r
+\r
+               /// <summary>\r
+               /// Executes a single command against a MySQL database.\r
+               /// </summary>\r
+               /// <param name="connectionString">Settings to use for this command</param>\r
+               /// <param name="commandText">Command text to use</param>\r
+               /// <param name="commandParameters">Array of <see cref="MySqlParameter"/> objects to use with the command</param>\r
+               /// <returns><see cref="MySqlDataReader"/> object ready to read the results of the command</returns>\r
+               public static MySqlDataReader ExecuteReader(string connectionString, string commandText, params MySqlParameter[] commandParameters)\r
+               {\r
+                       //create & open a SqlConnection\r
+                       MySqlConnection cn = new MySqlConnection(connectionString);\r
+                       cn.Open();\r
+\r
+                       try\r
+                       {\r
+                               //call the private overload that takes an internally owned connection in place of the connection string\r
+                               return ExecuteReader(cn, null, commandText, commandParameters, false );\r
+                       }\r
+                       catch\r
+                       {\r
+                               //if we fail to return the SqlDatReader, we need to close the connection ourselves\r
+                               cn.Close();\r
+                               throw;\r
+                       }\r
+               }\r
+               #endregion\r
+\r
+               #region ExecuteScalar\r
+\r
+               /// <summary>\r
+               /// Execute a single command against a MySQL database.\r
+               /// </summary>\r
+               /// <param name="connectionString">Settings to use for the update</param>\r
+               /// <param name="commandText">Command text to use for the update</param>\r
+               /// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>\r
+               public static object ExecuteScalar(string connectionString, string commandText)\r
+               {\r
+                       //pass through the call providing null for the set of MySqlParameters\r
+                       return ExecuteScalar(connectionString, commandText, (MySqlParameter[])null);\r
+               }\r
+\r
+               /// <summary>\r
+               /// Execute a single command against a MySQL database.\r
+               /// </summary>\r
+               /// <param name="connectionString">Settings to use for the command</param>\r
+               /// <param name="commandText">Command text to use for the command</param>\r
+               /// <param name="commandParameters">Parameters to use for the command</param>\r
+               /// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>\r
+               public static object ExecuteScalar(string connectionString, string commandText, params MySqlParameter[] commandParameters)\r
+               {\r
+                       //create & open a SqlConnection, and dispose of it after we are done.\r
+                       using (MySqlConnection cn = new MySqlConnection(connectionString))\r
+                       {\r
+                               cn.Open();\r
+\r
+                               //call the overload that takes a connection in place of the connection string\r
+                               return ExecuteScalar(cn, commandText, commandParameters);\r
+                       }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Execute a single command against a MySQL database.\r
+               /// </summary>\r
+               /// <param name="connection"><see cref="MySqlConnection"/> object to use</param>\r
+               /// <param name="commandText">Command text to use for the command</param>\r
+               /// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>\r
+               public static object ExecuteScalar(MySqlConnection connection, string commandText)\r
+               {\r
+                       //pass through the call providing null for the set of MySqlParameters\r
+                       return ExecuteScalar(connection, commandText, (MySqlParameter[])null);\r
+               }\r
+\r
+               /// <summary>\r
+               /// Execute a single command against a MySQL database.\r
+               /// </summary>\r
+               /// <param name="connection"><see cref="MySqlConnection"/> object to use</param>\r
+               /// <param name="commandText">Command text to use for the command</param>\r
+               /// <param name="commandParameters">Parameters to use for the command</param>\r
+               /// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>\r
+               public static object ExecuteScalar(MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters)\r
+               {\r
+                       //create a command and prepare it for execution\r
+                       MySqlCommand cmd = new MySqlCommand();\r
+                       cmd.Connection = connection;\r
+                       cmd.CommandText = commandText;\r
+                       cmd.CommandType = CommandType.Text;\r
+                       \r
+                       if (commandParameters != null)\r
+                               foreach (MySqlParameter p in commandParameters)\r
+                                       cmd.Parameters.Add( p );\r
+                       \r
+                       //execute the command & return the results\r
+                       object retval = cmd.ExecuteScalar();\r
+                       \r
+                       // detach the SqlParameters from the command object, so they can be used again.\r
+                       cmd.Parameters.Clear();\r
+                       return retval;\r
+                       \r
+               }\r
+\r
+               #endregion\r
+       }\r
+}\r
index bc4828c5e199e31aa7061a1af0b7b790c7dbe64d..09bfdaf79fc714aed31b2bfbdaf5b71d2a25669e 100644 (file)
-using System;
-using ByteFX.Data.Common;
-using System.Collections;
-
-namespace ByteFX.Data.MySqlClient
-{
-       /// <summary>
-       /// Summary description for MySqlPool.
-       /// </summary>
-       internal sealed class MySqlPool
-       {
-               private ArrayList                               inUsePool;
-               private ArrayList                               idlePool;
-               private MySqlConnectionString   settings;
-               private int                                             minSize;
-               private int                                             maxSize;
-
-               public MySqlPool(MySqlConnectionString settings)
-               {
-                       minSize = settings.MinPoolSize;
-                       maxSize = settings.MaxPoolSize;
-                       this.settings = settings;
-                       inUsePool =new ArrayList();
-                       idlePool = new ArrayList( settings.MinPoolSize );
-
-                       // prepopulate the idle pool to minSize
-                       for (int i=0; i < minSize; i++) 
-                               CreateNewPooledConnection();
-               }
-
-               private void CheckOutConnection(MySqlInternalConnection conn) 
-               {
-               }
-
-               private MySqlInternalConnection GetPooledConnection()
-               {
-                       MySqlInternalConnection conn = null;
-
-                       // if there are no idle connections and the in use pool is full
-                       // then return null to indicate that we cannot provide a connection
-                       // at this time.
-                       if (idlePool.Count == 0 && inUsePool.Count == maxSize) return null;
-
-                       lock (idlePool.SyncRoot) 
-                       {
-                               for (int i=idlePool.Count-1; i >=0; i--)
-                               {
-                                       conn = (idlePool[i] as MySqlInternalConnection);
-                                       if (conn.IsAlive()) 
-                                       {
-                                               lock (inUsePool) 
-                                               {
-                                                       inUsePool.Add( conn );
-                                               }
-                                               idlePool.RemoveAt( i );
-                                               return conn;
-                                       }
-                                       else 
-                                       {
-                                               conn.Close();
-                                               idlePool.RemoveAt(i);
-                                       }
-                               }
-                       }
-
-                       // if we couldn't get a pooled connection and there is still room
-                       // make a new one
-                       if (conn == null && (idlePool.Count+inUsePool.Count) < maxSize)
-                       {
-                               conn = CreateNewPooledConnection();
-                               if (conn == null) return null;
-
-                               lock (idlePool.SyncRoot)
-                                       lock (inUsePool.SyncRoot) 
-                                       {
-                                               idlePool.Remove( conn );
-                                               inUsePool.Add( conn );
-                                       }
-                       }
-
-                       return conn;
-               }
-
-               private MySqlInternalConnection CreateNewPooledConnection()
-               {
-                       lock(idlePool.SyncRoot) 
-                               lock (inUsePool.SyncRoot)
-                               {
-                                       // first we check if we are allowed to create another
-                                       if ((inUsePool.Count + idlePool.Count) == maxSize) return null;
-
-                                       MySqlInternalConnection conn = new MySqlInternalConnection( settings );
-                                       conn.Open();
-                                       idlePool.Add( conn );
-                                       return conn;
-                               }
-               }
-
-               public void ReleaseConnection( MySqlInternalConnection connection )
-               {
-                       lock (idlePool.SyncRoot)
-                               lock (inUsePool.SyncRoot) 
-                               {
-                                       inUsePool.Remove( connection );
-                                       if (connection.Settings.ConnectionLifetime != 0 && connection.IsTooOld())
-                                               connection.Close();
-                                       else
-                                               idlePool.Add( connection );
-                               }
-               }
-
-               public MySqlInternalConnection GetConnection() 
-               {
-                       MySqlInternalConnection conn = null;
-
-                       int start = Environment.TickCount;
-                       int ticks = settings.ConnectTimeout * 1000;
-
-                       // wait timeOut seconds at most to get a connection
-                       while (conn == null && (Environment.TickCount - start) < ticks)
-                               conn = GetPooledConnection();
-                                        
-                       // if pool size is at maximum, then we must have reached our timeout so we simply
-                       // throw our exception
-                       if (conn == null)
-                               throw new MySqlException("error connecting: Timeout expired.  The timeout period elapsed " + 
-                                       "prior to obtaining a connection from the pool.  This may have occurred because all " +
-                                       "pooled connections were in use and max pool size was reached.");
-
-                       return conn;
-               }
-
-       }
-}
+using System;\r
+using ByteFX.Data.Common;\r
+using System.Collections;\r
+\r
+namespace ByteFX.Data.MySqlClient\r
+{\r
+       /// <summary>\r
+       /// Summary description for MySqlPool.\r
+       /// </summary>\r
+       internal sealed class MySqlPool\r
+       {\r
+               private ArrayList                               inUsePool;\r
+               private ArrayList                               idlePool;\r
+               private MySqlConnectionString   settings;\r
+               private int                                             minSize;\r
+               private int                                             maxSize;\r
+\r
+               public MySqlPool(MySqlConnectionString settings)\r
+               {\r
+                       minSize = settings.MinPoolSize;\r
+                       maxSize = settings.MaxPoolSize;\r
+                       this.settings = settings;\r
+                       inUsePool =new ArrayList();\r
+                       idlePool = new ArrayList( settings.MinPoolSize );\r
+\r
+                       // prepopulate the idle pool to minSize\r
+                       for (int i=0; i < minSize; i++) \r
+                               CreateNewPooledConnection();\r
+               }\r
+\r
+               private void CheckOutConnection(MySqlInternalConnection conn) \r
+               {\r
+               }\r
+\r
+               private MySqlInternalConnection GetPooledConnection()\r
+               {\r
+                       MySqlInternalConnection conn = null;\r
+\r
+                       // if there are no idle connections and the in use pool is full\r
+                       // then return null to indicate that we cannot provide a connection\r
+                       // at this time.\r
+                       if (idlePool.Count == 0 && inUsePool.Count == maxSize) return null;\r
+\r
+                       lock (idlePool.SyncRoot) \r
+                       {\r
+                               for (int i=idlePool.Count-1; i >=0; i--)\r
+                               {\r
+                                       conn = (idlePool[i] as MySqlInternalConnection);\r
+                                       if (conn.IsAlive()) \r
+                                       {\r
+                                               lock (inUsePool) \r
+                                               {\r
+                                                       inUsePool.Add( conn );\r
+                                               }\r
+                                               idlePool.RemoveAt( i );\r
+                                               return conn;\r
+                                       }\r
+                                       else \r
+                                       {\r
+                                               conn.Close();\r
+                                               idlePool.RemoveAt(i);\r
+                                               conn = null;\r
+                                       }\r
+                               }\r
+                       }\r
+\r
+                       // if we couldn't get a pooled connection and there is still room\r
+                       // make a new one\r
+                       if (conn == null && (idlePool.Count+inUsePool.Count) < maxSize)\r
+                       {\r
+                               conn = CreateNewPooledConnection();\r
+                               if (conn == null) return null;\r
+\r
+                               lock (idlePool.SyncRoot)\r
+                                       lock (inUsePool.SyncRoot) \r
+                                       {\r
+                                               idlePool.Remove( conn );\r
+                                               inUsePool.Add( conn );\r
+                                       }\r
+                       }\r
+\r
+                       return conn;\r
+               }\r
+\r
+               private MySqlInternalConnection CreateNewPooledConnection()\r
+               {\r
+                       lock(idlePool.SyncRoot) \r
+                               lock (inUsePool.SyncRoot)\r
+                               {\r
+                                       // first we check if we are allowed to create another\r
+                                       if ((inUsePool.Count + idlePool.Count) == maxSize) return null;\r
+\r
+                                       MySqlInternalConnection conn = new MySqlInternalConnection( settings );\r
+                                       conn.Open();\r
+                                       idlePool.Add( conn );\r
+                                       return conn;\r
+                               }\r
+               }\r
+\r
+               public void ReleaseConnection( MySqlInternalConnection connection )\r
+               {\r
+                       lock (idlePool.SyncRoot)\r
+                               lock (inUsePool.SyncRoot) \r
+                               {\r
+                                       inUsePool.Remove( connection );\r
+                                       if (connection.Settings.ConnectionLifetime != 0 && connection.IsTooOld())\r
+                                               connection.Close();\r
+                                       else\r
+                                               idlePool.Add( connection );\r
+                               }\r
+               }\r
+\r
+               public MySqlInternalConnection GetConnection() \r
+               {\r
+                       MySqlInternalConnection conn = null;\r
+\r
+                       int start = Environment.TickCount;\r
+                       int ticks = settings.ConnectionTimeout * 1000;\r
+\r
+                       // wait timeOut seconds at most to get a connection\r
+                       while (conn == null && (Environment.TickCount - start) < ticks)\r
+                               conn = GetPooledConnection();\r
+                                        \r
+                       // if pool size is at maximum, then we must have reached our timeout so we simply\r
+                       // throw our exception\r
+                       if (conn == null)\r
+                               throw new MySqlException("error connecting: Timeout expired.  The timeout period elapsed " + \r
+                                       "prior to obtaining a connection from the pool.  This may have occurred because all " +\r
+                                       "pooled connections were in use and max pool size was reached.");\r
+\r
+                       return conn;\r
+               }\r
+\r
+       }\r
+}\r
index d1b418476ef44e85d3b359d189022a79d207bc10..ed3257569cd6afc18ec8c7890f1d28c2d78fd393 100644 (file)
@@ -1,63 +1,63 @@
-using System;
-using ByteFX.Data.Common;
-using System.Collections;
-
-namespace ByteFX.Data.MySqlClient
-{
-       /// <summary>
-       /// Summary description for MySqlPoolManager.
-       /// </summary>
-       internal sealed class MySqlPoolManager
-       {
-               private static Hashtable        pools;
-
-               public MySqlPoolManager() 
-               {
-               }
-
-               /// <summary>
-               /// 
-               /// </summary>
-               private static void Initialize()
-               {
-                       pools = new Hashtable();
-               }
-
-               public static MySqlInternalConnection GetConnection( MySqlConnectionString settings ) 
-               {
-                       // make sure the manager is initialized
-                       if (MySqlPoolManager.pools == null)
-                               MySqlPoolManager.Initialize();
-
-                       string text = settings.ConnectString;
-
-                       lock( pools.SyncRoot ) 
-                       {
-                               MySqlPool pool;
-                               if (!pools.Contains( text )) 
-                               {
-                                       pool = new MySqlPool( settings );
-                                       pools.Add( text, pool );
-                               }
-                               else 
-                               {
-                                       pool = (pools[text] as MySqlPool);
-                               }
-
-                               return pool.GetConnection();
-                       }
-               }
-
-               public static void ReleaseConnection( MySqlInternalConnection connection )
-               {
-                       lock (pools.SyncRoot) 
-                       {
-                               string key = connection.Settings.ConnectString;
-                               MySqlPool pool = (MySqlPool)pools[ key ];
-                               if (pool == null)
-                                       throw new MySqlException("Pooling exception: Unable to find original pool for connection");
-                               pool.ReleaseConnection(connection);
-                       }
-               }
-       }
-}
+using System;\r
+using ByteFX.Data.Common;\r
+using System.Collections;\r
+\r
+namespace ByteFX.Data.MySqlClient\r
+{\r
+       /// <summary>\r
+       /// Summary description for MySqlPoolManager.\r
+       /// </summary>\r
+       internal sealed class MySqlPoolManager\r
+       {\r
+               private static Hashtable        pools;\r
+\r
+               public MySqlPoolManager() \r
+               {\r
+               }\r
+\r
+               /// <summary>\r
+               /// \r
+               /// </summary>\r
+               private static void Initialize()\r
+               {\r
+                       pools = new Hashtable();\r
+               }\r
+\r
+               public static MySqlInternalConnection GetConnection( MySqlConnectionString settings ) \r
+               {\r
+                       // make sure the manager is initialized\r
+                       if (MySqlPoolManager.pools == null)\r
+                               MySqlPoolManager.Initialize();\r
+\r
+                       string text = settings.GetConnectionString();\r
+\r
+                       lock( pools.SyncRoot ) \r
+                       {\r
+                               MySqlPool pool;\r
+                               if (!pools.Contains( text )) \r
+                               {\r
+                                       pool = new MySqlPool( settings );\r
+                                       pools.Add( text, pool );\r
+                               }\r
+                               else \r
+                               {\r
+                                       pool = (pools[text] as MySqlPool);\r
+                               }\r
+\r
+                               return pool.GetConnection();\r
+                       }\r
+               }\r
+\r
+               public static void ReleaseConnection( MySqlInternalConnection connection )\r
+               {\r
+                       lock (pools.SyncRoot) \r
+                       {\r
+                               string key = connection.Settings.GetConnectionString();\r
+                               MySqlPool pool = (MySqlPool)pools[ key ];\r
+                               if (pool == null)\r
+                                       throw new MySqlException("Pooling exception: Unable to find original pool for connection");\r
+                               pool.ReleaseConnection(connection);\r
+                       }\r
+               }\r
+       }\r
+}\r
index faa027765a63df064f514b3f4a2c178606950cbd..31fd7f96512c8d6060707fcb5a828787a52790ce 100644 (file)
-// ByteFX.Data data access components for .Net
-// Copyright (C) 2002-2003  ByteFX, Inc.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// 
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-// 
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-using System;
-using System.IO;
-using System.Net;
-using System.Net.Sockets;
-using ByteFX.Data.Common;
-using System.Threading;
-
-namespace ByteFX.Data.MySqlClient
-{
-       /// <summary>
-       /// Summary description for API.
-       /// </summary>
-       internal class MySqlStream : MultiHostStream
-       {
-               public MySqlStream( string hostList, int port, int readTimeOut, int connectTimeOut ) :
-                       base( hostList, port, readTimeOut, connectTimeOut )
-
-               {
-               }
-
-               protected override void Error(string msg)
-               {
-                       throw new MySqlException( msg, baseException );
-               }
-
-               protected override void TimeOut(MultiHostStreamErrorType error) 
-               {
-                       switch (error) 
-                       {
-                               case MultiHostStreamErrorType.Connecting:
-                                       throw new MySqlException("Timed out creating a new MySqlConnection");
-                               case MultiHostStreamErrorType.Reading:
-                                       throw new MySqlException("Timed out reading from MySql");
-                       }
-               }
-
-               protected override bool CreateStream( IPAddress ip, string hostname, int port )
-               {
-                       if (port == -1)
-                               return CreatePipeStream(ip, hostname);
-                       else
-                               return CreateSocketStream(ip, port);
-               }
-
-               private bool CreatePipeStream( IPAddress ip, string hostname )
-               {
-                       string pipeName;
-
-                       if (hostname.ToLower().Equals("localhost"))
-                               pipeName = @"\\.\pipe\MySql";
-                       else
-                               pipeName = String.Format(@"\\{0}\pipe\MySql", ip.ToString());
-
-                       try 
-                       {
-                               stream = new NamedPipeStream(pipeName, FileAccess.ReadWrite);
-                               return true;
-                       }
-                       catch (Exception ex) 
-                       {
-                               baseException = ex;
-                               return false;
-                       }
-               }
-
-               private bool CreateSocketStream( IPAddress ip, int port )
-               {
-                       Socket socket = new Socket(AddressFamily.InterNetwork, 
-                               SocketType.Stream, ProtocolType.Tcp);
-
-                       try
-                       {
-                               //
-                               // Lets try to connect
-                               IPEndPoint endPoint     = new IPEndPoint( ip, port);
-                               socket.Connect(endPoint);
-                               socket.SetSocketOption( SocketOptionLevel.Tcp, SocketOptionName.NoDelay, 1 );
-                               stream = new NetworkStream( socket, true );
-                               return true;
-                       }
-                       catch (Exception ex)
-                       {
-                               baseException = ex;
-                               return false;
-                       }
-               }
-
-               protected override bool DataAvailable
-               {
-                       get 
-                       {
-                               if (stream is NetworkStream)
-                                       return ((NetworkStream)stream).DataAvailable;
-                               else return (stream as NamedPipeStream).DataAvailable;
-                       }
-               }
-
-               public int ReadInt24()
-               {
-                       byte[] bytes = new byte[3];
-                       Read( bytes, 0, 3 );
-                       return (bytes[0] + (bytes[1]*256) + (bytes[2]*256*256));
-               }
-
-               public override void Close()
-               {
-                       stream.Close();
-               }
-
-       }
-}
-
-
+// ByteFX.Data data access components for .Net\r
+// Copyright (C) 2002-2003  ByteFX, Inc.\r
+// Copyright (C) 2003  PT Cakram Datalingga Duaribu (http://www.cdl2000.com)\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License, or (at your option) any later version.\r
+// \r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+// Lesser General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+\r
+using System;\r
+using System.IO;\r
+using System.Net;\r
+using System.Net.Sockets;\r
+using ByteFX.Data.Common;\r
+using System.Threading;\r
+#if __MonoCS__ \r
+using Mono.Posix;\r
+#endif\r
+\r
+namespace ByteFX.Data.MySqlClient\r
+{\r
+       /// <summary>\r
+       /// Summary description for API.\r
+       /// </summary>\r
+       internal class MySqlStream : MultiHostStream\r
+       {\r
+               private Socket socket;\r
+\r
+               public MySqlStream( string hostList, int port, int readTimeOut, int connectTimeOut ) :\r
+                       base( hostList, port, readTimeOut, connectTimeOut )\r
+\r
+               {\r
+               }\r
+\r
+               protected override void Error(string msg)\r
+               {\r
+                       throw new MySqlException( msg, baseException );\r
+               }\r
+\r
+               protected override void TimeOut(MultiHostStreamErrorType error) \r
+               {\r
+                       switch (error) \r
+                       {\r
+                               case MultiHostStreamErrorType.Connecting:\r
+                                       throw new MySqlException("Timed out creating a new MySqlConnection");\r
+                               case MultiHostStreamErrorType.Reading:\r
+                                       throw new MySqlException("Timed out reading from MySql");\r
+                       }\r
+               }\r
+\r
+               protected override bool CreateStream( IPAddress ip, string hostname, int port )\r
+               {\r
+                       if (port == -1)\r
+                               return CreatePipeStream(ip, hostname);\r
+                       else\r
+                               return CreateSocketStream(ip, port);\r
+               }\r
+\r
+               protected override bool CreateStream (string filename)\r
+               {\r
+                       return CreateUnixSocketStream (filename);\r
+               }\r
+\r
+               private bool CreatePipeStream( IPAddress ip, string hostname )\r
+               {\r
+                       string pipeName;\r
+\r
+                       if (hostname.ToLower().Equals("localhost"))\r
+                               pipeName = @"\\.\pipe\MySql";\r
+                       else\r
+                               pipeName = String.Format(@"\\{0}\pipe\MySql", ip.ToString());\r
+\r
+                       try \r
+                       {\r
+                               stream = new NamedPipeStream(pipeName, FileAccess.ReadWrite);\r
+                               return true;\r
+                       }\r
+                       catch (Exception ex) \r
+                       {\r
+                               baseException = ex;\r
+                               return false;\r
+                       }\r
+               }\r
+\r
+               private bool CreateSocketStream( IPAddress ip, int port )\r
+               {\r
+                       socket = new Socket(AddressFamily.InterNetwork, \r
+                               SocketType.Stream, ProtocolType.Tcp);\r
+\r
+                       try\r
+                       {\r
+                               //\r
+                               // Lets try to connect\r
+                               IPEndPoint endPoint     = new IPEndPoint( ip, port);\r
+                               socket.Connect(endPoint);\r
+                               socket.SetSocketOption( SocketOptionLevel.Tcp, SocketOptionName.NoDelay, 1 );\r
+                               stream = new NetworkStream( socket, true );\r
+                               socket.Blocking = false;\r
+                               return true;\r
+                       }\r
+                       catch (Exception ex)\r
+                       {\r
+                               baseException = ex;\r
+                               return false;\r
+                       }\r
+               }\r
+\r
+               private bool CreateUnixSocketStream(string socketName)\r
+               {\r
+#if __MonoCS__ && !WINDOWS\r
+                       Socket socket = new Socket (AddressFamily.Unix, SocketType.Stream, ProtocolType.IP);\r
+\r
+                       try\r
+                       {\r
+                               UnixEndPoint endPoint = new UnixEndPoint (socketName);\r
+                               socket.Connect (endPoint);\r
+                               stream = new NetworkStream (socket, true);\r
+                               return true;\r
+                       }\r
+                       catch (Exception ex)\r
+                       {\r
+                               baseException = ex;\r
+                               return false;\r
+                       }\r
+#else\r
+                       baseException = new PlatformNotSupportedException ("This is not a Unix");\r
+                       return false;\r
+#endif\r
+               }\r
+\r
+               protected override bool DataAvailable\r
+               {\r
+                       get \r
+                       {\r
+                               if (stream is NetworkStream)\r
+                                       return ((NetworkStream)stream).DataAvailable;\r
+                               else return (stream as NamedPipeStream).DataAvailable;\r
+                       }\r
+               }\r
+\r
+               public int ReadInt24()\r
+               {\r
+                       byte[] bytes = new byte[3];\r
+                       Read( bytes, 0, 3 );\r
+                       return (bytes[0] + (bytes[1]*256) + (bytes[2]*256*256));\r
+               }\r
+\r
+               public override void Close()\r
+               {\r
+                       stream.Close();\r
+               }\r
+\r
+       }\r
+}\r
+\r
+\r
index 570e48eeb8d2d5fffb01ebe424be6eb7dbdf7ba2..9eeaac8cd7d40be3cd5a20fccdd5236956658213 100755 (executable)
-// ByteFX.Data data access components for .Net
-// Copyright (C) 2002-2003  ByteFX, Inc.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// 
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-// 
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-using System;
-
-namespace ByteFX.Data.MySqlClient
-{
-       /// <summary>
-       /// Summary description for ClientParam.
-       /// </summary>
-       [Flags()]
-       internal enum ClientParam
-       {
-               CLIENT_LONG_PASSWORD    = 1,                    // new more secure passwords
-               CLIENT_FOUND_ROWS               = 2,                    // found instead of affected rows
-               CLIENT_LONG_FLAG                = 4,                    // Get all column flags
-               CLIENT_CONNECT_WITH_DB  = 8,                    // One can specify db on connect
-               CLIENT_NO_SCHEMA                = 16,                   // Don't allow db.table.column
-               CLIENT_COMPRESS                 = 32,                   // Client can use compression protocol
-               CLIENT_ODBC                             = 64,                   // ODBC client
-               CLIENT_LOCAL_FILES              = 128,                  // Can use LOAD DATA LOCAL
-               CLIENT_IGNORE_SPACE             = 256,                  // Ignore spaces before '('
-               CLIENT_CHANGE_USER              = 512,                  // Support the mysql_change_user()
-               CLIENT_INTERACTIVE              = 1024,                 // This is an interactive client
-               CLIENT_SSL                              = 2048,                 // Switch to SSL after handshake
-               CLIENT_IGNORE_SIGPIPE   = 4096,                 // IGNORE sigpipes
-               CLIENT_TRANSACTIONS             = 8192,                 // Client knows about transactions
-               CLIENT_PROTOCOL_41              = 16384,
-               CLIENT_SECURE_CONNECTION = 32768
-
-       }
-       
-
-       /// <summary>
-       /// DB Operations Code
-       /// </summary>
-       internal enum DBCmd : byte
-       {
-               SLEEP        =  0,
-               QUIT         =  1,
-               INIT_DB      =  2,
-               QUERY        =  3,
-               FIELD_LIST   =  4,
-               CREATE_DB    =  5,
-               DROP_DB      =  6,
-               RELOAD       =  7,
-               SHUTDOWN     =  8,
-               STATISTICS   =  9,
-               PROCESS_INFO = 10,
-               CONNECT      = 11,
-               PROCESS_KILL = 12,
-               DEBUG        = 13,
-               PING         = 14,
-               TIME         = 15,
-               DELAYED_INSERT = 16,
-               CHANGE_USER    = 17,
-       }
-
-       /// <summary>
-       /// Specifies MySQL specific data type of a field, property, for use in a <see cref="MySqlParameter"/>.
-       /// </summary>
-       public enum MySqlDbType
-       {
-               /// <summary> <see cref="Decimal"/><para>A fixed precision and scale numeric value between -1038 -1 and 10 38 -1.</para></summary>
-               Decimal         =   0,  
-               /// <summary> <see cref="Byte"/><para>The signed range is -128 to 127. The unsigned range is 0 to 255.</para></summary>
-               Byte            =   1,  
-               /// <summary><see cref="Int16"/><para>A 16-bit signed or unsigned integer. The signed range is -32768 to 32767. The unsigned range is 0 to 65535</para></summary>
-               Short       =   2,
-               /// <summary><see cref="Int32"/><para>A 32-bit signed or unsigned integer</para></summary>
-               Int         =   3,
-               /// <summary><b>Obsolete</b>  Please use Int for 32 bit values</summary>
-               [Obsolete("Long is no longer the correct way of specifying a 32 bit value.  Use Int")]
-               Long        =   3,
-               /// <summary><see cref="Single"/><para>A small (single-precision) floating-point number. Allowable values are -3.402823466E+38 to -1.175494351E-38, 0, and 1.175494351E-38 to 3.402823466E+38.</para></summary>
-               Float       =   4,
-               /// <summary><see cref="Double"/><para>A normal-size (double-precision) floating-point number. Allowable values are -1.7976931348623157E+308 to -2.2250738585072014E-308, 0, and 2.2250738585072014E-308 to 1.7976931348623157E+308.</para></summary>
-               Double      =   5,
-               /// <summary>Specifies a null value</summary>
-               Null        =   6,
-               /// <summary>A timestamp. The range is '1970-01-01 00:00:00' to sometime in the year 2037</summary>
-               Timestamp   =   7,
-               /// <summary><see cref="Int64"/><para>A 64-bit signed or unsigned integer.</para></summary>
-               BigInt      =   8,
-               /// <summary><b>Obsolete</b>  Please use BigInt for 64 bit values</summary>
-               [Obsolete("LongLong is no longer the correct way of specifying a 64 bit value.  Use BigInt")]
-               LongLong    =   8,
-               /// <summary>Specifies a 24 (3 byte) signed or unsigned value.</summary>
-               Int24       =   9,
-               ///<summary>Date The supported range is '1000-01-01' to '9999-12-31'.</summary>
-               Date        =  10,
-               /// <summary> Time <para>The range is '-838:59:59' to '838:59:59'.</para></summary>
-               Time        =  11,
-               ///<summary>DateTime The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'.</summary>
-               Datetime    =  12,  
-               /// <summary>A year in 2- or 4-digit format (default is 4-digit). The allowable values are 1901 to 2155, 0000 in the 4-digit year format, and 1970-2069 if you use the 2-digit format (70-69)</summary>
-               Year        =  13,
-               /// <summary><b>Obsolete</b>  Use Datetime or Date type</summary>
-               Newdate     =  14,
-               /// <summary>An enumeration. A string object that can have only one value, chosen from the list of values 'value1', 'value2', ..., NULL or the special "" error value. An ENUM can have a maximum of 65535 distinct values</summary>
-               Enum        = 247,
-               /// <summary>A set. A string object that can have zero or more values, each of which must be chosen from the list of values 'value1', 'value2', ... A SET can have a maximum of 64 members.</summary>
-               Set         = 248,
-               /// <summary>A BLOB or TEXT column with a maximum length of 255 (2^8 - 1) characters</summary>
-               TinyBlob    = 249,
-               /// <summary>A BLOB or TEXT column with a maximum length of 16777215 (2^24 - 1) characters</summary>
-               MediumBlob  = 250,
-               /// <summary>A BLOB or TEXT column with a maximum length of 4294967295 or 4G (2^32 - 1) characters</summary>
-               LongBlob    = 251,
-               /// <summary>A BLOB or TEXT column with a maximum length of 65535 (2^16 - 1) characters</summary>
-               Blob        = 252,
-               /// <summary>A variable-length string containing 0 to 255 characters</summary>
-               VarChar     = 253,
-               /// <summary><b>Obsolete</b>  Use VarChar type</summary>
-               String      = 254
-       };
-
-
-       enum Field_Type : byte
-       {
-               DECIMAL                                 =0,
-               BYTE                                    =1,
-               SHORT                                   =2,
-               LONG                                    =3,
-               FLOAT                                   =4,
-               DOUBLE                                  =5,
-               NULL                                    =6,
-               TIMESTAMP                               =7,
-               LONGLONG                                =8,
-               INT24                                   =9,
-               DATE                                    =10,
-               TIME                                    =11,
-               DATETIME                                =12,
-               YEAR                                    =13,
-               NEWDATE                                 =14,
-               ENUM                                    =247,
-               SET                                             =248,
-               TINY_BLOB                               =249,
-               MEDIUM_BLOB                             =250,
-               LONG_BLOB                               =251,
-               BLOB                                    =252,
-               VAR_STRING                              =253,
-               STRING                                  =254,
-       }
-}
+// ByteFX.Data data access components for .Net\r
+// Copyright (C) 2002-2003  ByteFX, Inc.\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License, or (at your option) any later version.\r
+// \r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+// Lesser General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+using System;\r
+\r
+namespace ByteFX.Data.MySqlClient\r
+{\r
+       /// <summary>\r
+       /// Summary description for ClientParam.\r
+       /// </summary>\r
+       [Flags()]\r
+       internal enum ClientParam\r
+       {\r
+               CLIENT_LONG_PASSWORD    = 1,                    // new more secure passwords\r
+               CLIENT_FOUND_ROWS               = 2,                    // found instead of affected rows\r
+               CLIENT_LONG_FLAG                = 4,                    // Get all column flags\r
+               CLIENT_CONNECT_WITH_DB  = 8,                    // One can specify db on connect\r
+               CLIENT_NO_SCHEMA                = 16,                   // Don't allow db.table.column\r
+               CLIENT_COMPRESS                 = 32,                   // Client can use compression protocol\r
+               CLIENT_ODBC                             = 64,                   // ODBC client\r
+               CLIENT_LOCAL_FILES              = 128,                  // Can use LOAD DATA LOCAL\r
+               CLIENT_IGNORE_SPACE             = 256,                  // Ignore spaces before '('\r
+               CLIENT_CHANGE_USER              = 512,                  // Support the mysql_change_user()\r
+               CLIENT_INTERACTIVE              = 1024,                 // This is an interactive client\r
+               CLIENT_SSL                              = 2048,                 // Switch to SSL after handshake\r
+               CLIENT_IGNORE_SIGPIPE   = 4096,                 // IGNORE sigpipes\r
+               CLIENT_TRANSACTIONS             = 8192,                 // Client knows about transactions\r
+               CLIENT_PROTOCOL_41              = 16384,\r
+               CLIENT_SECURE_CONNECTION = 32768\r
+\r
+       }\r
+       \r
+\r
+       /// <summary>\r
+       /// DB Operations Code\r
+       /// </summary>\r
+       internal enum DBCmd : byte\r
+       {\r
+               SLEEP        =  0,\r
+               QUIT         =  1,\r
+               INIT_DB      =  2,\r
+               QUERY        =  3,\r
+               FIELD_LIST   =  4,\r
+               CREATE_DB    =  5,\r
+               DROP_DB      =  6,\r
+               RELOAD       =  7,\r
+               SHUTDOWN     =  8,\r
+               STATISTICS   =  9,\r
+               PROCESS_INFO = 10,\r
+               CONNECT      = 11,\r
+               PROCESS_KILL = 12,\r
+               DEBUG        = 13,\r
+               PING         = 14,\r
+               TIME         = 15,\r
+               DELAYED_INSERT = 16,\r
+               CHANGE_USER    = 17,\r
+       }\r
+\r
+       /// <summary>\r
+       /// Specifies MySQL specific data type of a field, property, for use in a <see cref="MySqlParameter"/>.\r
+       /// </summary>\r
+       public enum MySqlDbType\r
+       {\r
+               /// <summary> <see cref="Decimal"/><para>A fixed precision and scale numeric value between -1038 -1 and 10 38 -1.</para></summary>\r
+               Decimal         =   0,  \r
+               /// <summary> <see cref="Byte"/><para>The signed range is -128 to 127. The unsigned range is 0 to 255.</para></summary>\r
+               Byte            =   1,  \r
+               /// <summary><see cref="Int16"/><para>A 16-bit signed or unsigned integer. The signed range is -32768 to 32767. The unsigned range is 0 to 65535</para></summary>\r
+               Short       =   2,\r
+               /// <summary><see cref="Int32"/><para>A 32-bit signed or unsigned integer</para></summary>\r
+               Int         =   3,\r
+               /// <summary><b>Obsolete</b>  Please use Int for 32 bit values</summary>\r
+               [Obsolete("Long is no longer the correct way of specifying a 32 bit value.  Use Int")]\r
+               Long        =   3,\r
+               /// <summary><see cref="Single"/><para>A small (single-precision) floating-point number. Allowable values are -3.402823466E+38 to -1.175494351E-38, 0, and 1.175494351E-38 to 3.402823466E+38.</para></summary>\r
+               Float       =   4,\r
+               /// <summary><see cref="Double"/><para>A normal-size (double-precision) floating-point number. Allowable values are -1.7976931348623157E+308 to -2.2250738585072014E-308, 0, and 2.2250738585072014E-308 to 1.7976931348623157E+308.</para></summary>\r
+               Double      =   5,\r
+               /// <summary>Specifies a null value</summary>\r
+               Null        =   6,\r
+               /// <summary>A timestamp. The range is '1970-01-01 00:00:00' to sometime in the year 2037</summary>\r
+               Timestamp   =   7,\r
+               /// <summary><see cref="Int64"/><para>A 64-bit signed or unsigned integer.</para></summary>\r
+               BigInt      =   8,\r
+               /// <summary><b>Obsolete</b>  Please use BigInt for 64 bit values</summary>\r
+               [Obsolete("LongLong is no longer the correct way of specifying a 64 bit value.  Use BigInt")]\r
+               LongLong    =   8,\r
+               /// <summary>Specifies a 24 (3 byte) signed or unsigned value.</summary>\r
+               Int24       =   9,\r
+               ///<summary>Date The supported range is '1000-01-01' to '9999-12-31'.</summary>\r
+               Date        =  10,\r
+               /// <summary> Time <para>The range is '-838:59:59' to '838:59:59'.</para></summary>\r
+               Time        =  11,\r
+               ///<summary>DateTime The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'.</summary>\r
+               Datetime    =  12,  \r
+               /// <summary>A year in 2- or 4-digit format (default is 4-digit). The allowable values are 1901 to 2155, 0000 in the 4-digit year format, and 1970-2069 if you use the 2-digit format (70-69)</summary>\r
+               Year        =  13,\r
+               /// <summary><b>Obsolete</b>  Use Datetime or Date type</summary>\r
+               Newdate     =  14,\r
+               /// <summary>An enumeration. A string object that can have only one value, chosen from the list of values 'value1', 'value2', ..., NULL or the special "" error value. An ENUM can have a maximum of 65535 distinct values</summary>\r
+               Enum        = 247,\r
+               /// <summary>A set. A string object that can have zero or more values, each of which must be chosen from the list of values 'value1', 'value2', ... A SET can have a maximum of 64 members.</summary>\r
+               Set         = 248,\r
+               /// <summary>A BLOB or TEXT column with a maximum length of 255 (2^8 - 1) characters</summary>\r
+               TinyBlob    = 249,\r
+               /// <summary>A BLOB or TEXT column with a maximum length of 16777215 (2^24 - 1) characters</summary>\r
+               MediumBlob  = 250,\r
+               /// <summary>A BLOB or TEXT column with a maximum length of 4294967295 or 4G (2^32 - 1) characters</summary>\r
+               LongBlob    = 251,\r
+               /// <summary>A BLOB or TEXT column with a maximum length of 65535 (2^16 - 1) characters</summary>\r
+               Blob        = 252,\r
+               /// <summary>A variable-length string containing 0 to 255 characters</summary>\r
+               VarChar     = 253,\r
+               /// <summary><b>Obsolete</b>  Use VarChar type</summary>\r
+               String      = 254\r
+       };\r
+\r
+\r
+       enum Field_Type : byte\r
+       {\r
+               DECIMAL                                 =0,\r
+               BYTE                                    =1,\r
+               SHORT                                   =2,\r
+               LONG                                    =3,\r
+               FLOAT                                   =4,\r
+               DOUBLE                                  =5,\r
+               NULL                                    =6,\r
+               TIMESTAMP                               =7,\r
+               LONGLONG                                =8,\r
+               INT24                                   =9,\r
+               DATE                                    =10,\r
+               TIME                                    =11,\r
+               DATETIME                                =12,\r
+               YEAR                                    =13,\r
+               NEWDATE                                 =14,\r
+               ENUM                                    =247,\r
+               SET                                             =248,\r
+               TINY_BLOB                               =249,\r
+               MEDIUM_BLOB                             =250,\r
+               LONG_BLOB                               =251,\r
+               BLOB                                    =252,\r
+               VAR_STRING                              =253,\r
+               STRING                                  =254,\r
+       }\r
+}\r
index ca4685e93df0e39986c24b629a688fe56b0209db..60e45fc0524d908ca818de48f6153ad9154586be 100644 (file)
-using System;
-using System.IO;
-using System.Text;
-
-namespace ByteFX.Data.MySqlClient
-{
-/*     internal enum PacketType 
-       {
-               None,
-               UpdateOrOk,
-               ResultSchema,
-               Last,
-               Auth,
-               Error,
-               LoadDataLocal,
-               Other
-       }*/
-
-       /// <summary>
-       /// Summary description for Packet.
-       /// </summary>
-       internal class Packet : MemoryStream
-       {
-               Encoding                encoding;
-               private static int      HEADER_LEN = 7;
-
-               public Packet() : base(256+HEADER_LEN)
-               {
-                       Position = HEADER_LEN;
-               }
-
-               public Packet(int len) : base(len+HEADER_LEN)
-               {
-                       Position = HEADER_LEN;
-               }
-
-               public Packet(byte[] bytes) : base(bytes, 0, bytes.Length, true, true)
-               {
-               }
-
-               public Encoding Encoding 
-               {
-                       set { encoding = value; }
-                       get { return encoding; }
-               }
-
-               public byte this[int index] 
-               {
-                       get { return GetBuffer()[index]; }
-               }
-
-               public new int Length 
-               {
-                       get { return (int)base.Length; }
-               }
-
-               public bool IsLastPacket()
-               {
-                       if (Length == 1 && this[0] == 0xfe) return true;
-                       return false;
-               }
-
-               public byte[] GetBytes( byte packetSeq ) 
-               {
-                       long oldPos = Position;
-                       Position = 3;
-                       WriteInteger( Length-HEADER_LEN, 3 );
-                       WriteByte( packetSeq );
-                       Position = oldPos;
-                       return GetBuffer();
-               }
-
-               public int ReadNBytes()
-               {
-                       byte c = (byte)ReadByte();
-                       if (c < 1 || c > 4) throw new MySqlException("Unexpected byte count received");
-                       return ReadInteger((int)c);
-               }
-
-               public string ReadLenString()
-               {
-                       int len = ReadLenInteger();
-
-                       byte[] buffer = new Byte[len];
-                       Read(buffer, 0, len);
-                       return encoding.GetString( buffer, 0, len);
-               }
-
-
-               /// <summary>
-               /// WriteInteger
-               /// </summary>
-               /// <param name="v"></param>
-               /// <param name="numbytes"></param>
-               public void WriteInteger( int v, int numbytes )
-               {
-                       int val = v;
-
-                       if (numbytes < 1 || numbytes > 4) 
-                               throw new ArgumentOutOfRangeException("Wrong byte count for WriteInteger");
-
-                       for (int x=0; x < numbytes; x++)
-                       {
-                               WriteByte( (byte)(val&0xff) );
-                               val >>= 8;
-                       }
-               }
-
-               /// <summary>
-               /// 
-               /// </summary>
-               /// <param name="numbytes"></param>
-               /// <returns></returns>
-               public int ReadInteger(int numbytes)
-               {
-                       int val = 0;
-                       int raise = 1;
-                       for (int x=0; x < numbytes; x++)
-                       {
-                               int b = ReadByte();
-                               val += (b*raise);
-                               raise *= 256;
-                       }
-                       return val;
-               }
-
-               /// <summary>
-               /// 
-               /// </summary>
-               /// <returns></returns>
-               public int ReadLenInteger()
-               {
-                       byte c  = (byte)ReadByte();
-
-                       switch(c) 
-                       {
-                               case 251 : return -1; 
-                               case 252 : return ReadInteger(2);
-                               case 253 : return ReadInteger(3);
-                               case 254 : return ReadInteger(4);
-                               default  : return c;
-                       }
-               }
-
-               public bool HasMoreData
-               {
-                       get { return Position < Length; }
-               }
-
-               #region String Functions
-               public string ReadString()
-               {
-                       System.Text.StringBuilder sb = new System.Text.StringBuilder();
-
-                       while ( HasMoreData )
-                       {
-                               byte b = (byte)ReadByte();
-                               if (b == 0) break;
-                               sb.Append( Convert.ToChar( b ));
-                       }
-
-                       return sb.ToString();
-               }
-
-               public void WriteString(string v, Encoding encoding)
-               {
-                       WriteStringNoNull(v, encoding);
-                       WriteByte(0);
-               }
-
-               public void WriteStringNoNull(string v, Encoding encoding)
-               {
-                       byte[] bytes = encoding.GetBytes(v);
-                       Write(bytes, 0, bytes.Length);
-               }
-
-               #endregion
-
-
-       }
-}
+using System;\r
+using System.IO;\r
+using System.Text;\r
+\r
+namespace ByteFX.Data.MySqlClient\r
+{\r
+       /// <summary>\r
+       /// Summary description for Packet.\r
+       /// </summary>\r
+       internal class Packet : MemoryStream\r
+       {\r
+               Encoding                encoding;\r
+               byte                    sequence;\r
+               int                             completeLen;\r
+               public static int   NULL_LEN=-1;\r
+               private int             shortLen = 2;\r
+               private int             intLen = 3;\r
+               private int             longLen = 4;\r
+               private bool    longInts = false;\r
+\r
+               public Packet(bool longInts) : base()\r
+               {\r
+                       LongInts = longInts;\r
+               }\r
+\r
+               public Packet(byte[] bytes, bool longInts) : base(bytes.Length)\r
+               {\r
+                       this.Write( bytes, 0, bytes.Length );\r
+                       Position = 0;\r
+                       LongInts = longInts;\r
+               }\r
+\r
+               public bool LongInts \r
+               {\r
+                       get { return longInts; }\r
+                       set \r
+                       { \r
+                               longInts = value; \r
+                               if (longInts) \r
+                               {\r
+                                       intLen = 4;\r
+                                       longLen = 8;\r
+                               }\r
+                       }\r
+               }\r
+\r
+               public int CompleteLength \r
+               {\r
+                       get { return completeLen; }\r
+                       set { completeLen = value; }\r
+               }\r
+\r
+               public byte Sequence \r
+               {\r
+                       get { return sequence; }\r
+                       set { sequence = value; }\r
+               }\r
+\r
+               public Encoding Encoding \r
+               {\r
+                       set { encoding = value; }\r
+                       get { return encoding; }\r
+               }\r
+\r
+               public void Clear()\r
+               {\r
+                       Position = 0;\r
+                       this.SetLength(0);\r
+               }\r
+\r
+               public byte this[int index] \r
+               {\r
+                       get \r
+                       { \r
+                               long pos = Position;\r
+                               Position = index;\r
+                               byte b = (byte)ReadByte();\r
+                               Position = pos;\r
+                               return b;\r
+                       }\r
+               }\r
+\r
+               public new int Length \r
+               {\r
+                       get { return (int)base.Length; }\r
+               }\r
+\r
+               public bool IsLastPacket()\r
+               {\r
+                       return (Length == 1 && this[0] == 0xfe);\r
+               }\r
+\r
+               public void Append( Packet p )\r
+               {\r
+                       long oldPos = Position;\r
+                       Position = Length;\r
+                       this.Write( p.GetBuffer(), 0, p.Length );\r
+                       Position = oldPos;\r
+               }\r
+\r
+               public Packet ReadPacket()\r
+               {\r
+                       if (! HasMoreData) return null;\r
+\r
+                       int len = this.ReadInteger(3);\r
+                       byte seq = (byte)this.ReadByte();\r
+                       byte[] buf = new byte[ len ];\r
+                       this.Read( buf, 0, len );\r
+                       Packet p = new Packet( buf, LongInts );\r
+                       p.Sequence = seq;\r
+                       p.Encoding = this.Encoding;\r
+                       return p;\r
+               }\r
+\r
+               public int ReadNBytes()\r
+               {\r
+                       byte c = (byte)ReadByte();\r
+                       if (c < 1 || c > 4) throw new MySqlException("Unexpected byte count received");\r
+                       return ReadInteger((int)c);\r
+               }\r
+\r
+               public string ReadLenString()\r
+               {\r
+                       long len = ReadLenInteger();\r
+\r
+                       byte[] buffer = new Byte[len];\r
+                       Read(buffer, 0, (int)len);\r
+                       return encoding.GetString( buffer, 0, (int)len);\r
+               }\r
+\r
+\r
+               /// <summary>\r
+               /// WriteInteger\r
+               /// </summary>\r
+               /// <param name="v"></param>\r
+               /// <param name="numbytes"></param>\r
+               public void WriteInteger( int v, int numbytes )\r
+               {\r
+                       int val = v;\r
+\r
+                       if (numbytes < 1 || numbytes > 4) \r
+                               throw new ArgumentOutOfRangeException("Wrong byte count for WriteInteger");\r
+\r
+                       for (int x=0; x < numbytes; x++)\r
+                       {\r
+                               WriteByte( (byte)(val&0xff) );\r
+                               val >>= 8;\r
+                       }\r
+               }\r
+\r
+               /// <summary>\r
+               /// \r
+               /// </summary>\r
+               /// <param name="numbytes"></param>\r
+               /// <returns></returns>\r
+               public int ReadInteger(int numbytes)\r
+               {\r
+                       int val = 0;\r
+                       int raise = 1;\r
+                       for (int x=0; x < numbytes; x++)\r
+                       {\r
+                               int b = ReadByte();\r
+                               val += (b*raise);\r
+                               raise *= 256;\r
+                       }\r
+                       return val;\r
+               }\r
+\r
+               /// <summary>\r
+               /// \r
+               /// </summary>\r
+               /// <returns></returns>\r
+               public long ReadLenInteger()\r
+               {\r
+                       byte c  = (byte)ReadByte();\r
+\r
+                       switch(c) \r
+                       {\r
+                               case 251 : return NULL_LEN; \r
+                               case 252 : return ReadInteger(shortLen);\r
+                               case 253 : return ReadInteger(intLen);\r
+                               case 254 : return ReadInteger(longLen);\r
+                               default  : return c;\r
+                       }\r
+               }\r
+\r
+               public bool HasMoreData\r
+               {\r
+                       get { return Position < Length; }\r
+               }\r
+\r
+               #region String Functions\r
+               public string ReadString()\r
+               {\r
+                       System.Text.StringBuilder sb = new System.Text.StringBuilder();\r
+\r
+                       while ( HasMoreData )\r
+                       {\r
+                               byte b = (byte)ReadByte();\r
+                               if (b == 0) break;\r
+                               sb.Append( Convert.ToChar( b ));\r
+                       }\r
+\r
+                       return sb.ToString();\r
+               }\r
+\r
+               public void WriteString(string v, Encoding encoding)\r
+               {\r
+                       WriteStringNoNull(v, encoding);\r
+                       WriteByte(0);\r
+               }\r
+\r
+               public void WriteStringNoNull(string v, Encoding encoding)\r
+               {\r
+                       byte[] bytes = encoding.GetBytes(v);\r
+                       Write(bytes, 0, bytes.Length);\r
+               }\r
+\r
+               #endregion\r
+\r
+\r
+       }\r
+}\r
index 1dd3a20e5f294c4a9aade8ae6af9b2ba5a9c0e46..1d1c7c446375d9b77aea6e0a0811e18084045db5 100755 (executable)
-// ByteFX.Data data access components for .Net
-// Copyright (C) 2002-2003  ByteFX, Inc.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// 
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-// 
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-using System;
-using System.Data;
-using System.ComponentModel;
-using System.Collections;
-
-namespace ByteFX.Data.MySqlClient
-{
-       /// <summary>
-       /// Represents a SQL statement to execute against a MySQL database. This class cannot be inherited.
-       /// </summary>
-       /// <include file='docs/MySqlCommand.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>
-#if WINDOWS
-       [System.Drawing.ToolboxBitmap( typeof(MySqlCommand), "Designers.command.bmp")]
-#endif
-       [System.ComponentModel.DesignerCategory("Code")]
-       public sealed class MySqlCommand : Component, IDbCommand, ICloneable
-       {
-               MySqlConnection                         connection;
-               MySqlTransaction                        curTransaction;
-               string                                          cmdText;
-               int                                                     updateCount;
-               UpdateRowSource                         updatedRowSource = UpdateRowSource.Both;
-               MySqlParameterCollection        parameters = new MySqlParameterCollection();
-               private ArrayList                       arraySql = new ArrayList();
-
-               /// <summary>
-               /// Overloaded. Initializes a new instance of the MySqlCommand class.
-               /// </summary>
-               public MySqlCommand()
-               {
-               }
-
-               /// <summary>
-               /// Overloaded. Initializes a new instance of the MySqlCommand class.
-               /// </summary>
-               public MySqlCommand(string cmdText)
-               {
-                       this.cmdText = cmdText;
-               }
-
-               /// <summary>
-               /// Overloaded. Initializes a new instance of the MySqlCommand class.
-               /// </summary>
-               public MySqlCommand(System.ComponentModel.IContainer container)
-               {
-                       // Required for Windows.Forms Class Composition Designer support
-                       container.Add(this);
-               }
-
-               /// <summary>
-               /// Overloaded. Initializes a new instance of the MySqlCommand class.
-               /// </summary>
-               public MySqlCommand(string cmdText, MySqlConnection connection)
-               {
-                       this.cmdText    = cmdText;
-                       this.connection  = connection;
-               }
-
-               /// <summary>
-               /// Disposes of this instance of MySqlCommand
-               /// </summary>
-               public new void Dispose() 
-               {
-                       base.Dispose();
-               }
-
-               /// <summary>
-               /// Overloaded. Initializes a new instance of the MySqlCommand class.
-               /// </summary>
-               public MySqlCommand(string cmdText, MySqlConnection connection, MySqlTransaction txn)
-               {
-                       this.cmdText    = cmdText;
-                       this.connection = connection;
-                       curTransaction  = txn;
-               } 
-
-               #region Properties
-
-               /// <summary>
-               /// Gets or sets the SQL statement to execute at the data source.
-               /// </summary>
-               [Category("Data")]
-               [Description("Command text to execute")]
-#if WINDOWS
-               [Editor(typeof(ByteFX.Data.Common.SqlCommandTextEditor), typeof(System.Drawing.Design.UITypeEditor))]
-#endif
-               public string CommandText
-               {
-                       get { return cmdText;  }
-                       set  { cmdText = value;  }
-               }
-
-               internal int UpdateCount 
-               {
-                       get { return updateCount; }
-               }
-
-               /// <summary>
-               /// Gets or sets the wait time before terminating the attempt to execute a command and generating an error.
-               /// </summary>
-               [Category("Misc")]
-               [Description("Time to wait for command to execute")]
-               public int CommandTimeout
-               {
-                       // TODO: support this
-                       get  { return 0; }
-                       set  { if (value != 0) throw new NotSupportedException(); }
-               }
-
-               /// <summary>
-               /// Gets or sets a value indicating how the CommandText property is to be interpreted.  Only
-               /// type Text is currently supported.
-               /// </summary>
-               [Category("Data")]
-               public CommandType CommandType
-               {
-                       get { return CommandType.Text; }
-                       set 
-                       { 
-                               if (value != CommandType.Text) 
-                                       throw new NotSupportedException("This version of the MySql provider only supports Text command types"); 
-                       }
-               }
-
-               /// <summary>
-               /// Gets or sets the MySqlConnection used by this instance of the MySqlCommand.
-               /// </summary>
-               [Category("Behavior")]
-               [Description("Connection used by the command")]
-               public IDbConnection Connection
-               {
-                       /*
-                       * The user should be able to set or change the connection at 
-                       * any time.
-                       */
-                       get 
-                       { 
-                               return connection;  
-                       }
-                       set
-                       {
-                               /*
-                               * The connection is associated with the transaction
-                               * so set the transaction object to return a null reference if the connection 
-                               * is reset.
-                               */
-                               if (connection != value)
-                               this.Transaction = null;
-
-                               connection = (MySqlConnection)value;
-                       }
-               }
-
-               /// <summary>
-               /// Gets the MySqlParameterCollection.
-               /// </summary>
-               [Category("Data")]
-               [Description("The parameters collection")]
-               [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
-               public MySqlParameterCollection Parameters
-               {
-                       get  { return parameters; }
-               }
-
-               IDataParameterCollection IDbCommand.Parameters
-               {
-                       get  { return parameters; }
-               }
-
-               /// <summary>
-               ///     Gets or sets the MySqlTransaction within which the MySqlCommand executes.
-               /// </summary>
-               [Browsable(false)]
-               public IDbTransaction Transaction
-               {
-                       /*
-                       * Set the transaction. Consider additional steps to ensure that the transaction
-                       * is compatible with the connection, because the two are usually linked.
-                       */
-                       get 
-                       { 
-                               return curTransaction; 
-                       }
-                       set 
-                       { 
-                               curTransaction = (MySqlTransaction)value; 
-                       }
-               }
-
-               /// <summary>
-               /// Gets or sets how command results are applied to the DataRow when used by the Update method of the DbDataAdapter.
-               /// </summary>
-               [Category("Behavior")]
-               public UpdateRowSource UpdatedRowSource
-               {
-                       get 
-                       { 
-                               return updatedRowSource;  
-                       }
-                       set 
-                       { 
-                               updatedRowSource = value; 
-                       }
-               }
-               #endregion
-
-               #region Methods
-               /// <summary>
-               /// Attempts to cancel the execution of a MySqlCommand.  This operation is not supported.
-               /// </summary>
-               /// <exception cref="NotSupportedException">This operation is not supported.</exception>
-               public void Cancel()
-               {
-                       throw new NotSupportedException();
-               }
-
-               /// <summary>
-               /// Creates a new instance of a MySqlParameter object.
-               /// </summary>
-               /// <returns></returns>
-               public MySqlParameter CreateParameter()
-               {
-                       return new MySqlParameter();
-               }
-
-               IDbDataParameter IDbCommand.CreateParameter()
-               {
-                       return CreateParameter();
-               }
-
-               private ArrayList SplitSql(string sql)
-               {
-                       ArrayList commands = new ArrayList();
-                       System.IO.MemoryStream ms = new System.IO.MemoryStream(sql.Length);
-
-                       // first we tack on a semi-colon, if not already there, to make our
-                       // sql processing code easier.  Then we ask our encoder to give us
-                       // the bytes for this sql string
-                       byte[] bytes = connection.Encoding.GetBytes(sql + ";");
-
-                       byte left_byte = 0;
-                       bool escaped = false;
-                       int  parm_start=-1;
-                       for (int x=0; x < bytes.Length; x++)
-                       {
-                               byte b = bytes[x];
-
-                               // if we see a quote marker, then check to see if we are opening
-                               // or closing a quote
-                               if ((b == '\'' || b == '\"') && ! escaped )
-                               {
-                                       if (b == left_byte) left_byte = 0;
-                                       else if (left_byte == 0) left_byte = b;
-                               }
-
-                               else if (b == '\\') 
-                               {
-                                       escaped = !escaped;
-                               }
-
-                                       // if we see the marker for a parameter, then save its position and
-                                       // look for the end
-                               else if (b == '@' && left_byte == 0 && ! escaped && parm_start==-1) 
-                                       parm_start = x;
-
-                                       // if we see a space and we are tracking a parameter, then end the parameter and have
-                                       // that parameter serialize itself to the memory stream
-                               else if (parm_start > -1 && (b != '@') && (b != '$') && (b != '_') && (b != '.') && ! Char.IsLetterOrDigit((char)b))
-                               {
-                                       string parm_name = sql.Substring(parm_start, x-parm_start); 
-
-                                       if (parameters.Contains( parm_name ))//p != null)
-                                       //if(parm_name.Length<2 || parm_name[1]!='@') // if doesn't begin with @@, do our processing.
-                                       {
-                                               MySqlParameter p = (parameters[parm_name] as MySqlParameter);
-                                               p.SerializeToBytes(ms, connection );
-                                       }
-                                       else
-                                       {
-                                               // otherwise assume system param. just write it out
-                                               byte[] buf = connection.Encoding.GetBytes(parm_name);
-                                               ms.Write(buf, 0, buf.Length); 
-                                       }
-                                       parm_start=-1;
-                               }
-
-                               // if we are not in a string and we are not escaped and we are on a semi-colon,
-                               // then write out what we have as a command
-                               if (left_byte == 0 && ! escaped && b == ';' && ms.Length > 0)
-                               {
-                                       bool goodcmd = false;
-                                       byte[] byteArray = ms.ToArray();
-                                       foreach (byte cmdByte in byteArray)
-                                               if (cmdByte != ' ') { goodcmd = true; break; }
-
-                                       if (goodcmd)
-                                               commands.Add( byteArray );
-                                       ms.SetLength(0);
-                               }
-                               else if (parm_start == -1)
-                                       ms.WriteByte(b);
-
-
-                               // we want to write out the bytes in all cases except when we are parsing out a parameter
-                               if (escaped && b != '\\') escaped = false;
-                       }
-
-                       return commands;
-               }
-
-               private void ReadOffResultSet()
-               {
-                       Driver driver = connection.InternalConnection.Driver;
-
-                       // first read off the schema
-                       Packet packet = driver.ReadPacket();
-                       while (! packet.IsLastPacket())
-                               packet = driver.ReadPacket();
-
-                       // now read off the data
-                       packet = driver.ReadPacket();
-                       while (! packet.IsLastPacket())
-                               packet = driver.ReadPacket();
-               }
-
-               /// <summary>
-               /// Internal function to execute the next command in an array of commands
-               /// </summary>
-               internal Packet ExecuteBatch( bool stopAtResultSet )
-               {
-                       Driver driver = connection.InternalConnection.Driver;
-
-                       while (arraySql.Count > 0)
-                       {
-                               byte[] sql = (byte[])arraySql[0];
-                               arraySql.RemoveAt(0);
-
-                               Packet packet =  driver.SendSql( sql );
-                               byte b = (byte)packet.ReadByte();
-                               if (b == 0) 
-                               {
-                                       if (updateCount == -1) updateCount = 0;
-                                       updateCount += (int)packet.ReadLenInteger();
-                               }
-                               else if (stopAtResultSet) 
-                               {
-                                       packet.Position--;
-                                       return packet;
-                               }
-                               else
-                                       ReadOffResultSet();
-                       }
-                       return null;
-               }
-
-               /// <summary>
-               /// Executes a SQL statement against the connection and returns the number of rows affected.
-               /// </summary>
-               /// <returns>Number of rows affected</returns>
-               public int ExecuteNonQuery()
-               {
-                       // There must be a valid and open connection.
-                       if (connection == null || connection.State != ConnectionState.Open)
-                               throw new InvalidOperationException("Connection must be valid and open");
-
-                       // Data readers have to be closed first
-                       if (connection.Reader != null)
-                               throw new MySqlException("There is already an open DataReader associated with this Connection which must be closed first.");
-
-                       // execute any commands left in the queue from before.
-                       //ExecuteBatch(false);
-                       
-                       arraySql = SplitSql( cmdText );
-                       updateCount = 0;
-
-                       ExecuteBatch(false);
-
-                       return (int)updateCount;
-               }
-
-               IDataReader IDbCommand.ExecuteReader ()
-               {
-                       return ExecuteReader ();
-               }
-
-               IDataReader IDbCommand.ExecuteReader (CommandBehavior behavior)
-               {
-                       return ExecuteReader (behavior);
-               }
-
-               /// <summary>
-               /// Overloaded. Sends the CommandText to the Connection and builds a MySqlDataReader.
-               /// </summary>
-               /// <returns></returns>
-               public MySqlDataReader ExecuteReader()
-               {
-                       return ExecuteReader(CommandBehavior.Default);
-               }
-
-
-               /// <summary>
-               /// Overloaded. Sends the CommandText to the Connection and builds a MySqlDataReader.
-               /// </summary>
-               /// <returns></returns>
-               public MySqlDataReader ExecuteReader(CommandBehavior behavior)
-               {
-                       // There must be a valid and open connection.
-                       if (connection == null || connection.State != ConnectionState.Open)
-                               throw new InvalidOperationException("Connection must be valid and open");
-
-                       // make sure all readers on this connection are closed
-                       if (connection.Reader != null)
-                               throw new InvalidOperationException("There is already an open DataReader associated with this Connection which must be closed first.");
-
-                       string sql = cmdText;
-
-                       if (0 != (behavior & CommandBehavior.KeyInfo))
-                       {
-                       }
-
-                       if (0 != (behavior & CommandBehavior.SchemaOnly))
-                       {
-                       }
-
-                       if (0 != (behavior & CommandBehavior.SequentialAccess))
-                       {
-                       }
-
-                       if (0 != (behavior & CommandBehavior.SingleResult))
-                       {
-                       }
-
-                       if (0 != (behavior & CommandBehavior.SingleRow))
-                       {
-                               sql = String.Format("SET SQL_SELECT_LIMIT=1;{0};SET sql_select_limit=-1;", cmdText);
-                       }
-
-                       arraySql = SplitSql( sql );
-
-                       updateCount = -1;
-                       MySqlDataReader reader = new MySqlDataReader(this, behavior);
-
-                       // move to the first resultset
-                       reader.NextResult();
-                       connection.Reader = reader;
-                       return reader;
-               }
-
-               /// <summary>
-               /// Executes the query, and returns the first column of the first row in the 
-               /// result set returned by the query. Extra columns or rows are ignored.
-               /// </summary>
-               /// <returns></returns>
-               public object ExecuteScalar()
-               {
-                       // There must be a valid and open connection.
-                       if (connection == null || connection.State != ConnectionState.Open)
-                               throw new InvalidOperationException("Connection must be valid and open");
-
-                       // Data readers have to be closed first
-                       if (connection.Reader != null)
-                               throw new MySqlException("There is already an open DataReader associated with this Connection which must be closed first.");
-
-                       arraySql = SplitSql( cmdText );
-
-                       updateCount = -1;
-                       MySqlDataReader reader = new MySqlDataReader(this, 0);
-                       reader.NextResult();
-                       object val = null;
-                       if (reader.Read())
-                               val = reader.GetValue(0);
-                       reader.Close();
-                       return val;
-               }
-
-               /// <summary>
-               /// Creates a prepared version of the command on an instance of MySQL Server. This
-               /// is currently not supported.
-               /// </summary>
-               public void Prepare()
-               {
-               }
-               #endregion
-
-               #region ICloneable
-               /// <summary>
-               /// Creates a clone of this MySqlCommand object.  CommandText, Connection, and Transaction properties
-               /// are included as well as the entire parameter list.
-               /// </summary>
-               /// <returns>The cloned MySqlCommand object</returns>
-               public object Clone() 
-               {
-                       MySqlCommand clone = new MySqlCommand(cmdText, connection, curTransaction);
-                       foreach (MySqlParameter p in parameters) 
-                       {
-                               clone.Parameters.Add((p as ICloneable).Clone());
-                       }
-                       return clone;
-               }
-               #endregion
-  }
-}
+// ByteFX.Data data access components for .Net\r
+// Copyright (C) 2002-2003  ByteFX, Inc.\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License, or (at your option) any later version.\r
+// \r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+// Lesser General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+\r
+using System;\r
+using System.Data;\r
+using System.ComponentModel;\r
+using System.Collections;\r
+\r
+namespace ByteFX.Data.MySqlClient\r
+{\r
+       /// <summary>\r
+       /// Represents a SQL statement to execute against a MySQL database. This class cannot be inherited.\r
+       /// </summary>\r
+       /// <include file='docs/MySqlCommand.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>\r
+#if WINDOWS\r
+       [System.Drawing.ToolboxBitmap( typeof(MySqlCommand), "MySqlClient.resources.command.bmp")]\r
+#endif\r
+       [System.ComponentModel.DesignerCategory("Code")]\r
+       public sealed class MySqlCommand : Component, IDbCommand, ICloneable\r
+       {\r
+               MySqlConnection                         connection;\r
+               MySqlTransaction                        curTransaction;\r
+               string                                          cmdText;\r
+               int                                                     updateCount;\r
+               UpdateRowSource                         updatedRowSource = UpdateRowSource.Both;\r
+               MySqlParameterCollection        parameters = new MySqlParameterCollection();\r
+               private ArrayList                       arraySql = new ArrayList();\r
+\r
+               /// <summary>\r
+               /// Overloaded. Initializes a new instance of the MySqlCommand class.\r
+               /// </summary>\r
+               public MySqlCommand()\r
+               {\r
+               }\r
+\r
+               /// <summary>\r
+               /// Overloaded. Initializes a new instance of the MySqlCommand class.\r
+               /// </summary>\r
+               public MySqlCommand(string cmdText)\r
+               {\r
+                       this.cmdText = cmdText;\r
+               }\r
+\r
+               /// <summary>\r
+               /// Overloaded. Initializes a new instance of the MySqlCommand class.\r
+               /// </summary>\r
+               public MySqlCommand(System.ComponentModel.IContainer container)\r
+               {\r
+                       // Required for Windows.Forms Class Composition Designer support\r
+                       container.Add(this);\r
+               }\r
+\r
+               /// <summary>\r
+               /// Overloaded. Initializes a new instance of the MySqlCommand class.\r
+               /// </summary>\r
+               public MySqlCommand(string cmdText, MySqlConnection connection)\r
+               {\r
+                       this.cmdText    = cmdText;\r
+                       this.connection  = connection;\r
+               }\r
+\r
+               /// <summary>\r
+               /// Disposes of this instance of MySqlCommand\r
+               /// </summary>\r
+               public new void Dispose() \r
+               {\r
+                       base.Dispose();\r
+               }\r
+\r
+               /// <summary>\r
+               /// Overloaded. Initializes a new instance of the MySqlCommand class.\r
+               /// </summary>\r
+               public MySqlCommand(string cmdText, MySqlConnection connection, MySqlTransaction txn)\r
+               {\r
+                       this.cmdText    = cmdText;\r
+                       this.connection = connection;\r
+                       curTransaction  = txn;\r
+               } \r
+\r
+               #region Properties\r
+\r
+               /// <summary>\r
+               /// Gets or sets the SQL statement to execute at the data source.\r
+               /// </summary>\r
+               [Category("Data")]\r
+               [Description("Command text to execute")]\r
+#if WINDOWS\r
+               [Editor("ByteFX.Data.Common.Design.SqlCommandTextEditor,MySqlClient.Design", typeof(System.Drawing.Design.UITypeEditor))]\r
+#endif\r
+               public string CommandText\r
+               {\r
+                       get { return cmdText;  }\r
+                       set  { cmdText = value;  }\r
+               }\r
+\r
+               internal int UpdateCount \r
+               {\r
+                       get { return updateCount; }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets or sets the wait time before terminating the attempt to execute a command and generating an error.\r
+               /// </summary>\r
+               [Category("Misc")]\r
+               [Description("Time to wait for command to execute")]\r
+               public int CommandTimeout\r
+               {\r
+                       // TODO: support this\r
+                       get  { return 0; }\r
+                       set  { if (value != 0) throw new NotSupportedException(); }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets or sets a value indicating how the CommandText property is to be interpreted.  Only\r
+               /// type Text is currently supported.\r
+               /// </summary>\r
+               [Category("Data")]\r
+               public CommandType CommandType\r
+               {\r
+                       get { return CommandType.Text; }\r
+                       set \r
+                       { \r
+                               if (value != CommandType.Text) \r
+                                       throw new NotSupportedException("This version of the MySql provider only supports Text command types"); \r
+                       }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets or sets the MySqlConnection used by this instance of the MySqlCommand.\r
+               /// </summary>\r
+               [Category("Behavior")]\r
+               [Description("Connection used by the command")]\r
+               public IDbConnection Connection\r
+               {\r
+                       /*\r
+                       * The user should be able to set or change the connection at \r
+                       * any time.\r
+                       */\r
+                       get \r
+                       { \r
+                               return connection;  \r
+                       }\r
+                       set\r
+                       {\r
+                               /*\r
+                               * The connection is associated with the transaction\r
+                               * so set the transaction object to return a null reference if the connection \r
+                               * is reset.\r
+                               */\r
+                               if (connection != value)\r
+                               this.Transaction = null;\r
+\r
+                               connection = (MySqlConnection)value;\r
+                       }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the MySqlParameterCollection.\r
+               /// </summary>\r
+               [Category("Data")]\r
+               [Description("The parameters collection")]\r
+               [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]\r
+               public MySqlParameterCollection Parameters\r
+               {\r
+                       get  { return parameters; }\r
+               }\r
+\r
+               IDataParameterCollection IDbCommand.Parameters\r
+               {\r
+                       get  { return parameters; }\r
+               }\r
+\r
+               /// <summary>\r
+               ///     Gets or sets the MySqlTransaction within which the MySqlCommand executes.\r
+               /// </summary>\r
+               [Browsable(false)]\r
+               public IDbTransaction Transaction\r
+               {\r
+                       /*\r
+                       * Set the transaction. Consider additional steps to ensure that the transaction\r
+                       * is compatible with the connection, because the two are usually linked.\r
+                       */\r
+                       get \r
+                       { \r
+                               return curTransaction; \r
+                       }\r
+                       set \r
+                       { \r
+                               curTransaction = (MySqlTransaction)value; \r
+                       }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets or sets how command results are applied to the DataRow when used by the Update method of the DbDataAdapter.\r
+               /// </summary>\r
+               [Category("Behavior")]\r
+               public UpdateRowSource UpdatedRowSource\r
+               {\r
+                       get \r
+                       { \r
+                               return updatedRowSource;  \r
+                       }\r
+                       set \r
+                       { \r
+                               updatedRowSource = value; \r
+                       }\r
+               }\r
+               #endregion\r
+\r
+               #region Methods\r
+               /// <summary>\r
+               /// Attempts to cancel the execution of a MySqlCommand.  This operation is not supported.\r
+               /// </summary>\r
+               /// <exception cref="NotSupportedException">This operation is not supported.</exception>\r
+               public void Cancel()\r
+               {\r
+                       throw new NotSupportedException();\r
+               }\r
+\r
+               /// <summary>\r
+               /// Creates a new instance of a MySqlParameter object.\r
+               /// </summary>\r
+               /// <returns></returns>\r
+               public MySqlParameter CreateParameter()\r
+               {\r
+                       return new MySqlParameter();\r
+               }\r
+\r
+               IDbDataParameter IDbCommand.CreateParameter()\r
+               {\r
+                       return CreateParameter();\r
+               }\r
+\r
+               private ArrayList SplitSql(string sql)\r
+               {\r
+                       ArrayList commands = new ArrayList();\r
+                       System.IO.MemoryStream ms = new System.IO.MemoryStream(sql.Length);\r
+\r
+                       // first we tack on a semi-colon, if not already there, to make our\r
+                       // sql processing code easier.  Then we ask our encoder to give us\r
+                       // the bytes for this sql string\r
+                       byte[] bytes = connection.Encoding.GetBytes(sql + ";");\r
+\r
+                       byte left_byte = 0;\r
+                       bool escaped = false;\r
+                       int  parm_start=-1;\r
+                       for (int x=0; x < bytes.Length; x++)\r
+                       {\r
+                               byte b = bytes[x];\r
+\r
+                               // if we see a quote marker, then check to see if we are opening\r
+                               // or closing a quote\r
+                               if ((b == '\'' || b == '\"') && ! escaped )\r
+                               {\r
+                                       if (b == left_byte) left_byte = 0;\r
+                                       else if (left_byte == 0) left_byte = b;\r
+                               }\r
+\r
+                               else if (b == '\\') \r
+                               {\r
+                                       escaped = !escaped;\r
+                               }\r
+\r
+                                       // if we see the marker for a parameter, then save its position and\r
+                                       // look for the end\r
+                               else if (b == '@' && left_byte == 0 && ! escaped && parm_start==-1) \r
+                                       parm_start = x;\r
+\r
+                                       // if we see a space and we are tracking a parameter, then end the parameter and have\r
+                                       // that parameter serialize itself to the memory stream\r
+                               else if (parm_start > -1 && (b != '@') && (b != '$') && (b != '_') && (b != '.') && ! Char.IsLetterOrDigit((char)b))\r
+                               {\r
+                                       string parm_name = sql.Substring(parm_start, x-parm_start); \r
+\r
+                                       if (parameters.Contains( parm_name ))\r
+                                       {\r
+                                               MySqlParameter p = (parameters[parm_name] as MySqlParameter);\r
+                                               p.SerializeToBytes(ms, connection );\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               // otherwise assume system param. just write it out\r
+                                               byte[] buf = connection.Encoding.GetBytes(parm_name);\r
+                                               ms.Write(buf, 0, buf.Length); \r
+                                       }\r
+                                       parm_start=-1;\r
+                               }\r
+\r
+                               // if we are not in a string and we are not escaped and we are on a semi-colon,\r
+                               // then write out what we have as a command\r
+                               if (left_byte == 0 && ! escaped && b == ';' && ms.Length > 0)\r
+                               {\r
+                                       bool goodcmd = false;\r
+                                       byte[] byteArray = ms.ToArray();\r
+                                       foreach (byte cmdByte in byteArray)\r
+                                               if (cmdByte != ' ') { goodcmd = true; break; }\r
+\r
+                                       if (goodcmd)\r
+                                               commands.Add( byteArray );\r
+                                       ms.SetLength(0);\r
+                               }\r
+                               else if (parm_start == -1)\r
+                                       ms.WriteByte(b);\r
+\r
+\r
+                               // we want to write out the bytes in all cases except when we are parsing out a parameter\r
+                               if (escaped && b != '\\') escaped = false;\r
+                       }\r
+\r
+                       return commands;\r
+               }\r
+\r
+               private void ReadOffResultSet()\r
+               {\r
+                       Driver driver = connection.InternalConnection.Driver;\r
+\r
+                       // first read off the schema\r
+                       Packet packet = driver.ReadPacket();\r
+                       while (! packet.IsLastPacket())\r
+                               packet = driver.ReadPacket();\r
+\r
+                       // now read off the data\r
+                       packet = driver.ReadPacket();\r
+                       while (! packet.IsLastPacket())\r
+                               packet = driver.ReadPacket();\r
+               }\r
+\r
+               /// <summary>\r
+               /// Internal function to execute the next command in an array of commands\r
+               /// </summary>\r
+               internal CommandResult ExecuteBatch( bool stopAtResultSet )\r
+               {\r
+                       Driver driver = connection.InternalConnection.Driver;\r
+\r
+                       while (arraySql.Count > 0)\r
+                       {\r
+                               byte[] sql = (byte[])arraySql[0];\r
+                               arraySql.RemoveAt(0);\r
+\r
+                               CommandResult result = driver.Send( DBCmd.QUERY, sql );\r
+                               \r
+                               if (result.IsResultSet)\r
+                               {\r
+                                       if (stopAtResultSet) return result;\r
+                                       result.Clear();\r
+                                       continue;\r
+                               }\r
+\r
+                               // at this point, we know it is a zero field count\r
+                               if (updateCount == -1) updateCount = 0;\r
+                               updateCount += result.RowsAffected;\r
+                       }\r
+                       return null;\r
+               }\r
+\r
+               /// <summary>\r
+               /// Executes a SQL statement against the connection and returns the number of rows affected.\r
+               /// </summary>\r
+               /// <returns>Number of rows affected</returns>\r
+               public int ExecuteNonQuery()\r
+               {\r
+                       // There must be a valid and open connection.\r
+                       if (connection == null || connection.State != ConnectionState.Open)\r
+                               throw new InvalidOperationException("Connection must be valid and open");\r
+\r
+                       // Data readers have to be closed first\r
+                       if (connection.Reader != null)\r
+                               throw new MySqlException("There is already an open DataReader associated with this Connection which must be closed first.");\r
+\r
+                       // execute any commands left in the queue from before.\r
+                       //ExecuteBatch(false);\r
+                       \r
+                       arraySql = SplitSql( cmdText );\r
+                       updateCount = 0;\r
+\r
+                       ExecuteBatch(false);\r
+\r
+                       return (int)updateCount;\r
+               }\r
+\r
+               IDataReader IDbCommand.ExecuteReader ()\r
+               {\r
+                       return ExecuteReader ();\r
+               }\r
+\r
+               IDataReader IDbCommand.ExecuteReader (CommandBehavior behavior)\r
+               {\r
+                       return ExecuteReader (behavior);\r
+               }\r
+\r
+               /// <summary>\r
+               /// Overloaded. Sends the CommandText to the Connection and builds a MySqlDataReader.\r
+               /// </summary>\r
+               /// <returns></returns>\r
+               public MySqlDataReader ExecuteReader()\r
+               {\r
+                       return ExecuteReader(CommandBehavior.Default);\r
+               }\r
+\r
+\r
+               /// <summary>\r
+               /// Overloaded. Sends the CommandText to the Connection and builds a MySqlDataReader.\r
+               /// </summary>\r
+               /// <returns></returns>\r
+               public MySqlDataReader ExecuteReader(CommandBehavior behavior)\r
+               {\r
+                       // There must be a valid and open connection.\r
+                       if (connection == null || connection.State != ConnectionState.Open)\r
+                               throw new InvalidOperationException("Connection must be valid and open");\r
+\r
+                       // make sure all readers on this connection are closed\r
+                       if (connection.Reader != null)\r
+                               throw new InvalidOperationException("There is already an open DataReader associated with this Connection which must be closed first.");\r
+\r
+                       string sql = cmdText;\r
+\r
+                       if (0 != (behavior & CommandBehavior.KeyInfo))\r
+                       {\r
+                       }\r
+\r
+                       if (0 != (behavior & CommandBehavior.SchemaOnly))\r
+                       {\r
+                       }\r
+\r
+                       if (0 != (behavior & CommandBehavior.SequentialAccess))\r
+                       {\r
+                       }\r
+\r
+                       if (0 != (behavior & CommandBehavior.SingleResult))\r
+                       {\r
+                       }\r
+\r
+                       if (0 != (behavior & CommandBehavior.SingleRow))\r
+                       {\r
+                               sql = String.Format("SET SQL_SELECT_LIMIT=1;{0};SET sql_select_limit=-1;", cmdText);\r
+                       }\r
+\r
+                       arraySql = SplitSql( sql );\r
+\r
+                       updateCount = -1;\r
+                       MySqlDataReader reader = new MySqlDataReader(this, behavior);\r
+\r
+                       // move to the first resultset\r
+                       reader.NextResult();\r
+                       connection.Reader = reader;\r
+                       return reader;\r
+               }\r
+\r
+               /// <summary>\r
+               /// Executes the query, and returns the first column of the first row in the \r
+               /// result set returned by the query. Extra columns or rows are ignored.\r
+               /// </summary>\r
+               /// <returns></returns>\r
+               public object ExecuteScalar()\r
+               {\r
+                       // There must be a valid and open connection.\r
+                       if (connection == null || connection.State != ConnectionState.Open)\r
+                               throw new InvalidOperationException("Connection must be valid and open");\r
+\r
+                       // Data readers have to be closed first\r
+                       if (connection.Reader != null)\r
+                               throw new MySqlException("There is already an open DataReader associated with this Connection which must be closed first.");\r
+\r
+                       arraySql = SplitSql( cmdText );\r
+\r
+                       updateCount = -1;\r
+                       MySqlDataReader reader = new MySqlDataReader(this, 0);\r
+                       reader.NextResult();\r
+                       object val = null;\r
+                       if (reader.Read())\r
+                               val = reader.GetValue(0);\r
+                       reader.Close();\r
+                       return val;\r
+               }\r
+\r
+               /// <summary>\r
+               /// Creates a prepared version of the command on an instance of MySQL Server. This\r
+               /// is currently not supported.\r
+               /// </summary>\r
+               public void Prepare()\r
+               {\r
+               }\r
+               #endregion\r
+\r
+               #region ICloneable\r
+               /// <summary>\r
+               /// Creates a clone of this MySqlCommand object.  CommandText, Connection, and Transaction properties\r
+               /// are included as well as the entire parameter list.\r
+               /// </summary>\r
+               /// <returns>The cloned MySqlCommand object</returns>\r
+               public object Clone() \r
+               {\r
+                       MySqlCommand clone = new MySqlCommand(cmdText, connection, curTransaction);\r
+                       foreach (MySqlParameter p in parameters) \r
+                       {\r
+                               clone.Parameters.Add((p as ICloneable).Clone());\r
+                       }\r
+                       return clone;\r
+               }\r
+               #endregion\r
+  }\r
+}\r
index 7e323966c18c06ea7fd44df07b63102db352eb20..6b3c4ce0a5ffa619d583a9ec4b09b49c9ee23c37 100755 (executable)
@@ -1,42 +1,42 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<root>
-       <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
-               <xsd:element name="root" msdata:IsDataSet="true">
-                       <xsd:complexType>
-                               <xsd:choice maxOccurs="unbounded">
-                                       <xsd:element name="data">
-                                               <xsd:complexType>
-                                                       <xsd:sequence>
-                                                               <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
-                                                               <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
-                                                       </xsd:sequence>
-                                                       <xsd:attribute name="name" type="xsd:string" />
-                                                       <xsd:attribute name="type" type="xsd:string" />
-                                                       <xsd:attribute name="mimetype" type="xsd:string" />
-                                               </xsd:complexType>
-                                       </xsd:element>
-                                       <xsd:element name="resheader">
-                                               <xsd:complexType>
-                                                       <xsd:sequence>
-                                                               <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
-                                                       </xsd:sequence>
-                                                       <xsd:attribute name="name" type="xsd:string" use="required" />
-                                               </xsd:complexType>
-                                       </xsd:element>
-                               </xsd:choice>
-                       </xsd:complexType>
-               </xsd:element>
-       </xsd:schema>
-       <resheader name="ResMimeType">
-               <value>text/microsoft-resx</value>
-       </resheader>
-       <resheader name="Version">
-               <value>1.0.0.0</value>
-       </resheader>
-       <resheader name="Reader">
-               <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
-       </resheader>
-       <resheader name="Writer">
-               <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
-       </resheader>
-</root>
+<?xml version="1.0" encoding="utf-8" ?>\r
+<root>\r
+       <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">\r
+               <xsd:element name="root" msdata:IsDataSet="true">\r
+                       <xsd:complexType>\r
+                               <xsd:choice maxOccurs="unbounded">\r
+                                       <xsd:element name="data">\r
+                                               <xsd:complexType>\r
+                                                       <xsd:sequence>\r
+                                                               <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+                                                               <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />\r
+                                                       </xsd:sequence>\r
+                                                       <xsd:attribute name="name" type="xsd:string" />\r
+                                                       <xsd:attribute name="type" type="xsd:string" />\r
+                                                       <xsd:attribute name="mimetype" type="xsd:string" />\r
+                                               </xsd:complexType>\r
+                                       </xsd:element>\r
+                                       <xsd:element name="resheader">\r
+                                               <xsd:complexType>\r
+                                                       <xsd:sequence>\r
+                                                               <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+                                                       </xsd:sequence>\r
+                                                       <xsd:attribute name="name" type="xsd:string" use="required" />\r
+                                               </xsd:complexType>\r
+                                       </xsd:element>\r
+                               </xsd:choice>\r
+                       </xsd:complexType>\r
+               </xsd:element>\r
+       </xsd:schema>\r
+       <resheader name="ResMimeType">\r
+               <value>text/microsoft-resx</value>\r
+       </resheader>\r
+       <resheader name="Version">\r
+               <value>1.0.0.0</value>\r
+       </resheader>\r
+       <resheader name="Reader">\r
+               <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+       </resheader>\r
+       <resheader name="Writer">\r
+               <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+       </resheader>\r
+</root>\r
index 8063783483424bef37cf129f57b44560cd782199..96bd1a49911f4b859172fc81b37299baa5568978 100755 (executable)
-// ByteFX.Data data access components for .Net
-// Copyright (C) 2002-2003  ByteFX, Inc.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// 
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-// 
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-using System.Data;
-using System.Data.Common;
-using System.ComponentModel;
-
-namespace ByteFX.Data.MySqlClient
-{
-       /// <summary>
-       /// Represents a set of data commands and a database connection that are used to fill a dataset and update a MySQL database. This class cannot be inherited.
-       /// </summary>
-       /// <include file='docs/MySqlDataAdapter.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>
-       [System.Drawing.ToolboxBitmap( typeof(MySqlDataAdapter), "Designers.dataadapter.bmp")]
-       [System.ComponentModel.DesignerCategory("Code")]
-       public sealed class MySqlDataAdapter : DbDataAdapter, IDbDataAdapter
-       {
-               private MySqlCommand m_selectCommand;
-               private MySqlCommand m_insertCommand;
-               private MySqlCommand m_updateCommand;
-               private MySqlCommand m_deleteCommand;
-
-               /*
-                       * Inherit from Component through DbDataAdapter. The event
-                       * mechanism is designed to work with the Component.Events
-                       * property. These variables are the keys used to find the
-                       * events in the components list of events.
-                       */
-               static private readonly object EventRowUpdated = new object(); 
-               static private readonly object EventRowUpdating = new object(); 
-
-
-               /// <summary>
-               /// Initializes a new instance of the MySqlDataAdapter class.
-               /// </summary>
-               public MySqlDataAdapter()
-               {
-               }
-
-               /// <summary>
-               /// Initializes a new instance of the MySqlDataAdapter class with the specified MySqlCommand as the SelectCommand property.
-               /// </summary>
-               /// <param name="selectCommand"></param>
-               public MySqlDataAdapter( MySqlCommand selectCommand ) 
-               {
-                       SelectCommand = selectCommand;
-               }
-
-               /// <summary>
-               /// Initializes a new instance of the MySqlDataAdapter class with a SelectCommand and a MySqlConnection object.
-               /// </summary>
-               /// <param name="selectCommandText"></param>
-               /// <param name="conn"></param>
-               public MySqlDataAdapter( string selectCommandText, MySqlConnection conn) 
-               {
-                       SelectCommand = new MySqlCommand( selectCommandText, conn );
-               }
-
-               /// <summary>
-               /// Initializes a new instance of the MySqlDataAdapter class with a SelectCommand and a connection string.
-               /// </summary>
-               /// <param name="selectCommandText"></param>
-               /// <param name="selectConnString"></param>
-               public MySqlDataAdapter( string selectCommandText, string selectConnString) 
-               {
-                       SelectCommand = new MySqlCommand( selectCommandText, 
-                               new MySqlConnection(selectConnString) );
-               }
-
-               #region Properties
-               /// <summary>
-               /// Gets or sets a SQL statement to delete records from the data set.
-               /// </summary>
-               [DataSysDescription("Used during Update for deleted rows in Dataset.")]
-               public MySqlCommand DeleteCommand 
-               {
-                       get { return m_deleteCommand; }
-                       set { m_deleteCommand = value; }
-               }
-
-               IDbCommand IDbDataAdapter.DeleteCommand 
-               {
-                       get { return m_deleteCommand; }
-                       set { m_deleteCommand = (MySqlCommand)value; }
-               }
-
-               /// <summary>
-               /// Gets or sets a SQL statement to insert new records into the data source.
-               /// </summary>
-               [DataSysDescription("Used during Update for new rows in Dataset.")]
-               public MySqlCommand InsertCommand 
-               {
-                       get { return m_insertCommand; }
-                       set { m_insertCommand = value; }
-               }
-
-               IDbCommand IDbDataAdapter.InsertCommand 
-               {
-                       get { return m_insertCommand; }
-                       set { m_insertCommand = (MySqlCommand)value; }
-               }
-
-               /// <summary>
-               /// Gets or sets a SQL statement used to select records in the data source.
-               /// </summary>
-               [DataSysDescription("Used during Fill/FillSchema")]
-               [Category("Fill")]
-               public MySqlCommand SelectCommand 
-               {
-                       get { return m_selectCommand; }
-                       set { m_selectCommand = value; }
-               }
-
-               IDbCommand IDbDataAdapter.SelectCommand 
-               {
-                       get { return m_selectCommand; }
-                       set { m_selectCommand = (MySqlCommand)value; }
-               }
-
-               /// <summary>
-               /// Gets or sets a SQL statement used to update records in the data source.
-               /// </summary>
-               [DataSysDescription("Used during Update for modified rows in Dataset.")]
-               public MySqlCommand UpdateCommand 
-               {
-                       get { return m_updateCommand; }
-                       set { m_updateCommand = value; }
-               }
-
-               IDbCommand IDbDataAdapter.UpdateCommand 
-               {
-                       get { return m_updateCommand; }
-                       set { m_updateCommand = (MySqlCommand)value; }
-               }
-
-               #endregion
-
-               /*
-                       * Implement abstract methods inherited from DbDataAdapter.
-                       */
-               /// <summary>
-               /// Overridden. See <see cref="DbDataAdapter.CreateRowUpdatedEvent"/>.
-               /// </summary>
-               /// <param name="dataRow"></param>
-               /// <param name="command"></param>
-               /// <param name="statementType"></param>
-               /// <param name="tableMapping"></param>
-               /// <returns></returns>
-               override protected RowUpdatedEventArgs CreateRowUpdatedEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
-               {
-                       return new MySqlRowUpdatedEventArgs(dataRow, command, statementType, tableMapping);
-               }
-
-               /// <summary>
-               /// Overridden. See <see cref="DbDataAdapter.CreateRowUpdatingEvent"/>.
-               /// </summary>
-               /// <param name="dataRow"></param>
-               /// <param name="command"></param>
-               /// <param name="statementType"></param>
-               /// <param name="tableMapping"></param>
-               /// <returns></returns>
-               override protected RowUpdatingEventArgs CreateRowUpdatingEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
-               {
-                       return new MySqlRowUpdatingEventArgs(dataRow, command, statementType, tableMapping);
-               }
-
-               /// <summary>
-               /// Overridden. Raises the RowUpdating event.
-               /// </summary>
-               /// <param name="value">A MySqlRowUpdatingEventArgs that contains the event data.</param>
-               override protected void OnRowUpdating(RowUpdatingEventArgs value)
-               {
-                       MySqlRowUpdatingEventHandler handler = (MySqlRowUpdatingEventHandler) Events[EventRowUpdating];
-                       if ((null != handler) && (value is MySqlRowUpdatingEventArgs)) 
-                       {
-                               handler(this, (MySqlRowUpdatingEventArgs) value);
-                       }
-               }
-
-               /// <summary>
-               /// Overridden. Raises the RowUpdated event.
-               /// </summary>
-               /// <param name="value">A MySqlRowUpdatedEventArgs that contains the event data. </param>
-               override protected void OnRowUpdated(RowUpdatedEventArgs value)
-               {
-                       MySqlRowUpdatedEventHandler handler = (MySqlRowUpdatedEventHandler) Events[EventRowUpdated];
-                       if ((null != handler) && (value is MySqlRowUpdatedEventArgs)) 
-                       {
-                               handler(this, (MySqlRowUpdatedEventArgs) value);
-                       }
-               }
-
-               /// <summary>
-               /// Occurs during Update before a command is executed against the data source. The attempt to update is made, so the event fires.
-               /// </summary>
-               public event MySqlRowUpdatingEventHandler RowUpdating
-               {
-                       add { Events.AddHandler(EventRowUpdating, value); }
-                       remove { Events.RemoveHandler(EventRowUpdating, value); }
-               }
-
-               /// <summary>
-               /// Occurs during Update after a command is executed against the data source. The attempt to update is made, so the event fires.
-               /// </summary>
-               public event MySqlRowUpdatedEventHandler RowUpdated
-               {
-                       add { Events.AddHandler(EventRowUpdated, value); }
-                       remove { Events.RemoveHandler(EventRowUpdated, value); }
-               }
-       }
-
-       /// <summary>
-       /// Represents the method that will handle the <see cref="MySqlDataAdapter.RowUpdating"/> event of a <see cref="MySqlDataAdapter"/>.
-       /// </summary>
-       public delegate void MySqlRowUpdatingEventHandler(object sender, MySqlRowUpdatingEventArgs e);
-
-       /// <summary>
-       /// Represents the method that will handle the <see cref="MySqlDataAdapter.RowUpdated"/> event of a <see cref="MySqlDataAdapter"/>.
-       /// </summary>
-       public delegate void MySqlRowUpdatedEventHandler(object sender, MySqlRowUpdatedEventArgs e);
-
-       /// <summary>
-       /// Provides data for the RowUpdating event. This class cannot be inherited.
-       /// </summary>
-       public sealed class MySqlRowUpdatingEventArgs : RowUpdatingEventArgs
-       {
-               /// <summary>
-               /// Initializes a new instance of the MySqlRowUpdatingEventArgs class.
-               /// </summary>
-               /// <param name="row">The <see cref="DataRow"/> to <see cref="DbDataAdapter.Update"/>.</param>
-               /// <param name="command">The <see cref="IDbCommand"/> to execute during <see cref="DbDataAdapter.Update"/>.</param>
-               /// <param name="statementType">One of the <see cref="StatementType"/> values that specifies the type of query executed.</param>
-               /// <param name="tableMapping">The <see cref="DataTableMapping"/> sent through an <see cref="DbDataAdapter.Update"/>.</param>
-               public MySqlRowUpdatingEventArgs(DataRow row, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) 
-                       : base(row, command, statementType, tableMapping) 
-               {
-               }
-
-               /// <summary>
-               /// Gets or sets the MySqlCommand to execute when performing the Update.
-               /// </summary>
-               new public MySqlCommand Command
-               {
-                       get  { return (MySqlCommand)base.Command; }
-                       set  { base.Command = value; }
-               }
-       }
-
-       /// <summary>
-       /// Provides data for the RowUpdated event. This class cannot be inherited.
-       /// </summary>
-       public sealed class MySqlRowUpdatedEventArgs : RowUpdatedEventArgs
-       {
-               /// <summary>
-               /// Initializes a new instance of the MySqlRowUpdatedEventArgs class.
-               /// </summary>
-               /// <param name="row">The <see cref="DataRow"/> sent through an <see cref="DbDataAdapter.Update"/>.</param>
-               /// <param name="command">The <see cref="IDbCommand"/> executed when <see cref="DbDataAdapter.Update"/> is called.</param>
-               /// <param name="statementType">One of the <see cref="StatementType"/> values that specifies the type of query executed.</param>
-               /// <param name="tableMapping">The <see cref="DataTableMapping"/> sent through an <see cref="DbDataAdapter.Update"/>.</param>
-               public MySqlRowUpdatedEventArgs(DataRow row, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
-                       : base(row, command, statementType, tableMapping) 
-               {
-               }
-
-               /// <summary>
-               /// Gets or sets the MySqlCommand executed when Update is called.
-               /// </summary>
-               new public MySqlCommand Command
-               {
-                       get  { return (MySqlCommand)base.Command; }
-               }
-       }
-}
+// ByteFX.Data data access components for .Net\r
+// Copyright (C) 2002-2003  ByteFX, Inc.\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License, or (at your option) any later version.\r
+// \r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+// Lesser General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+\r
+using System.Data;\r
+using System.Data.Common;\r
+using System.ComponentModel;\r
+\r
+namespace ByteFX.Data.MySqlClient\r
+{\r
+       /// <summary>\r
+       /// Represents a set of data commands and a database connection that are used to fill a dataset and update a MySQL database. This class cannot be inherited.\r
+       /// </summary>\r
+       /// <include file='docs/MySqlDataAdapter.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>\r
+       [System.Drawing.ToolboxBitmap( typeof(MySqlDataAdapter), "MySqlClient.resources.dataadapter.bmp")]\r
+       [System.ComponentModel.DesignerCategory("Code")]\r
+       [Designer("ByteFX.Data.MySqlClient.Design.MySqlDataAdapterDesigner,MySqlClient.Design")]\r
+       public sealed class MySqlDataAdapter : DbDataAdapter, IDbDataAdapter\r
+       {\r
+               private MySqlCommand m_selectCommand;\r
+               private MySqlCommand m_insertCommand;\r
+               private MySqlCommand m_updateCommand;\r
+               private MySqlCommand m_deleteCommand;\r
+\r
+               /*\r
+                       * Inherit from Component through DbDataAdapter. The event\r
+                       * mechanism is designed to work with the Component.Events\r
+                       * property. These variables are the keys used to find the\r
+                       * events in the components list of events.\r
+                       */\r
+               static private readonly object EventRowUpdated = new object(); \r
+               static private readonly object EventRowUpdating = new object(); \r
+\r
+\r
+               /// <summary>\r
+               /// Initializes a new instance of the MySqlDataAdapter class.\r
+               /// </summary>\r
+               public MySqlDataAdapter()\r
+               {\r
+               }\r
+\r
+               /// <summary>\r
+               /// Initializes a new instance of the MySqlDataAdapter class with the specified MySqlCommand as the SelectCommand property.\r
+               /// </summary>\r
+               /// <param name="selectCommand"></param>\r
+               public MySqlDataAdapter( MySqlCommand selectCommand ) \r
+               {\r
+                       SelectCommand = selectCommand;\r
+               }\r
+\r
+               /// <summary>\r
+               /// Initializes a new instance of the MySqlDataAdapter class with a SelectCommand and a MySqlConnection object.\r
+               /// </summary>\r
+               /// <param name="selectCommandText"></param>\r
+               /// <param name="conn"></param>\r
+               public MySqlDataAdapter( string selectCommandText, MySqlConnection conn) \r
+               {\r
+                       SelectCommand = new MySqlCommand( selectCommandText, conn );\r
+               }\r
+\r
+               /// <summary>\r
+               /// Initializes a new instance of the MySqlDataAdapter class with a SelectCommand and a connection string.\r
+               /// </summary>\r
+               /// <param name="selectCommandText"></param>\r
+               /// <param name="selectConnString"></param>\r
+               public MySqlDataAdapter( string selectCommandText, string selectConnString) \r
+               {\r
+                       SelectCommand = new MySqlCommand( selectCommandText, \r
+                               new MySqlConnection(selectConnString) );\r
+               }\r
+\r
+               #region Properties\r
+               /// <summary>\r
+               /// Gets or sets a SQL statement to delete records from the data set.\r
+               /// </summary>\r
+               [Description("Used during Update for deleted rows in Dataset.")]\r
+               public MySqlCommand DeleteCommand \r
+               {\r
+                       get { return m_deleteCommand; }\r
+                       set { m_deleteCommand = value; }\r
+               }\r
+\r
+               IDbCommand IDbDataAdapter.DeleteCommand \r
+               {\r
+                       get { return m_deleteCommand; }\r
+                       set { m_deleteCommand = (MySqlCommand)value; }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets or sets a SQL statement to insert new records into the data source.\r
+               /// </summary>\r
+               [Description("Used during Update for new rows in Dataset.")]\r
+               public MySqlCommand InsertCommand \r
+               {\r
+                       get { return m_insertCommand; }\r
+                       set { m_insertCommand = value; }\r
+               }\r
+\r
+               IDbCommand IDbDataAdapter.InsertCommand \r
+               {\r
+                       get { return m_insertCommand; }\r
+                       set { m_insertCommand = (MySqlCommand)value; }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets or sets a SQL statement used to select records in the data source.\r
+               /// </summary>\r
+               [Description("Used during Fill/FillSchema")]\r
+               [Category("Fill")]\r
+               public MySqlCommand SelectCommand \r
+               {\r
+                       get { return m_selectCommand; }\r
+                       set { m_selectCommand = value; }\r
+               }\r
+\r
+               IDbCommand IDbDataAdapter.SelectCommand \r
+               {\r
+                       get { return m_selectCommand; }\r
+                       set { m_selectCommand = (MySqlCommand)value; }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets or sets a SQL statement used to update records in the data source.\r
+               /// </summary>\r
+               [Description("Used during Update for modified rows in Dataset.")]\r
+               public MySqlCommand UpdateCommand \r
+               {\r
+                       get { return m_updateCommand; }\r
+                       set { m_updateCommand = value; }\r
+               }\r
+\r
+               IDbCommand IDbDataAdapter.UpdateCommand \r
+               {\r
+                       get { return m_updateCommand; }\r
+                       set { m_updateCommand = (MySqlCommand)value; }\r
+               }\r
+\r
+               #endregion\r
+\r
+               /*\r
+                       * Implement abstract methods inherited from DbDataAdapter.\r
+                       */\r
+               /// <summary>\r
+               /// Overridden. See <see cref="DbDataAdapter.CreateRowUpdatedEvent"/>.\r
+               /// </summary>\r
+               /// <param name="dataRow"></param>\r
+               /// <param name="command"></param>\r
+               /// <param name="statementType"></param>\r
+               /// <param name="tableMapping"></param>\r
+               /// <returns></returns>\r
+               override protected RowUpdatedEventArgs CreateRowUpdatedEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)\r
+               {\r
+                       return new MySqlRowUpdatedEventArgs(dataRow, command, statementType, tableMapping);\r
+               }\r
+\r
+               /// <summary>\r
+               /// Overridden. See <see cref="DbDataAdapter.CreateRowUpdatingEvent"/>.\r
+               /// </summary>\r
+               /// <param name="dataRow"></param>\r
+               /// <param name="command"></param>\r
+               /// <param name="statementType"></param>\r
+               /// <param name="tableMapping"></param>\r
+               /// <returns></returns>\r
+               override protected RowUpdatingEventArgs CreateRowUpdatingEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)\r
+               {\r
+                       return new MySqlRowUpdatingEventArgs(dataRow, command, statementType, tableMapping);\r
+               }\r
+\r
+               /// <summary>\r
+               /// Overridden. Raises the RowUpdating event.\r
+               /// </summary>\r
+               /// <param name="value">A MySqlRowUpdatingEventArgs that contains the event data.</param>\r
+               override protected void OnRowUpdating(RowUpdatingEventArgs value)\r
+               {\r
+                       MySqlRowUpdatingEventHandler handler = (MySqlRowUpdatingEventHandler) Events[EventRowUpdating];\r
+                       if ((null != handler) && (value is MySqlRowUpdatingEventArgs)) \r
+                       {\r
+                               handler(this, (MySqlRowUpdatingEventArgs) value);\r
+                       }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Overridden. Raises the RowUpdated event.\r
+               /// </summary>\r
+               /// <param name="value">A MySqlRowUpdatedEventArgs that contains the event data. </param>\r
+               override protected void OnRowUpdated(RowUpdatedEventArgs value)\r
+               {\r
+                       MySqlRowUpdatedEventHandler handler = (MySqlRowUpdatedEventHandler) Events[EventRowUpdated];\r
+                       if ((null != handler) && (value is MySqlRowUpdatedEventArgs)) \r
+                       {\r
+                               handler(this, (MySqlRowUpdatedEventArgs) value);\r
+                       }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Occurs during Update before a command is executed against the data source. The attempt to update is made, so the event fires.\r
+               /// </summary>\r
+               public event MySqlRowUpdatingEventHandler RowUpdating\r
+               {\r
+                       add { Events.AddHandler(EventRowUpdating, value); }\r
+                       remove { Events.RemoveHandler(EventRowUpdating, value); }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Occurs during Update after a command is executed against the data source. The attempt to update is made, so the event fires.\r
+               /// </summary>\r
+               public event MySqlRowUpdatedEventHandler RowUpdated\r
+               {\r
+                       add { Events.AddHandler(EventRowUpdated, value); }\r
+                       remove { Events.RemoveHandler(EventRowUpdated, value); }\r
+               }\r
+       }\r
+\r
+       /// <summary>\r
+       /// Represents the method that will handle the <see cref="MySqlDataAdapter.RowUpdating"/> event of a <see cref="MySqlDataAdapter"/>.\r
+       /// </summary>\r
+       public delegate void MySqlRowUpdatingEventHandler(object sender, MySqlRowUpdatingEventArgs e);\r
+\r
+       /// <summary>\r
+       /// Represents the method that will handle the <see cref="MySqlDataAdapter.RowUpdated"/> event of a <see cref="MySqlDataAdapter"/>.\r
+       /// </summary>\r
+       public delegate void MySqlRowUpdatedEventHandler(object sender, MySqlRowUpdatedEventArgs e);\r
+\r
+       /// <summary>\r
+       /// Provides data for the RowUpdating event. This class cannot be inherited.\r
+       /// </summary>\r
+       public sealed class MySqlRowUpdatingEventArgs : RowUpdatingEventArgs\r
+       {\r
+               /// <summary>\r
+               /// Initializes a new instance of the MySqlRowUpdatingEventArgs class.\r
+               /// </summary>\r
+               /// <param name="row">The <see cref="DataRow"/> to <see cref="DbDataAdapter.Update"/>.</param>\r
+               /// <param name="command">The <see cref="IDbCommand"/> to execute during <see cref="DbDataAdapter.Update"/>.</param>\r
+               /// <param name="statementType">One of the <see cref="StatementType"/> values that specifies the type of query executed.</param>\r
+               /// <param name="tableMapping">The <see cref="DataTableMapping"/> sent through an <see cref="DbDataAdapter.Update"/>.</param>\r
+               public MySqlRowUpdatingEventArgs(DataRow row, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) \r
+                       : base(row, command, statementType, tableMapping) \r
+               {\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets or sets the MySqlCommand to execute when performing the Update.\r
+               /// </summary>\r
+               new public MySqlCommand Command\r
+               {\r
+                       get  { return (MySqlCommand)base.Command; }\r
+                       set  { base.Command = value; }\r
+               }\r
+       }\r
+\r
+       /// <summary>\r
+       /// Provides data for the RowUpdated event. This class cannot be inherited.\r
+       /// </summary>\r
+       public sealed class MySqlRowUpdatedEventArgs : RowUpdatedEventArgs\r
+       {\r
+               /// <summary>\r
+               /// Initializes a new instance of the MySqlRowUpdatedEventArgs class.\r
+               /// </summary>\r
+               /// <param name="row">The <see cref="DataRow"/> sent through an <see cref="DbDataAdapter.Update"/>.</param>\r
+               /// <param name="command">The <see cref="IDbCommand"/> executed when <see cref="DbDataAdapter.Update"/> is called.</param>\r
+               /// <param name="statementType">One of the <see cref="StatementType"/> values that specifies the type of query executed.</param>\r
+               /// <param name="tableMapping">The <see cref="DataTableMapping"/> sent through an <see cref="DbDataAdapter.Update"/>.</param>\r
+               public MySqlRowUpdatedEventArgs(DataRow row, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)\r
+                       : base(row, command, statementType, tableMapping) \r
+               {\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets or sets the MySqlCommand executed when Update is called.\r
+               /// </summary>\r
+               new public MySqlCommand Command\r
+               {\r
+                       get  { return (MySqlCommand)base.Command; }\r
+               }\r
+       }\r
+}\r
index bc166c5325305019cfe224f757841cbe7e55be0f..96f1fa2e24e1fcdab19a8066b3e33920e0c5b195 100755 (executable)
-// ByteFX.Data data access components for .Net
-// Copyright (C) 2002-2003  ByteFX, Inc.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// 
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-// 
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-using System;
-using System.Data;
-using System.Collections;
-
-namespace ByteFX.Data.MySqlClient
-{
-       /// <summary>
-       /// Provides a means of reading a forward-only stream of rows from a MySQL database. This class cannot be inherited.
-       /// </summary>
-       /// <include file='docs/MySqlDataReader.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>
-       public sealed class MySqlDataReader : MarshalByRefObject, IEnumerable, IDataReader, IDisposable, IDataRecord
-       {
-               // The DataReader should always be open when returned to the user.
-               private bool                    isOpen = true;
-
-               // Keep track of the results and position
-               // within the resultset (starts prior to first record).
-               private MySqlField[]    _fields;
-               private CommandBehavior commandBehavior;
-               private MySqlCommand    command;
-               private bool                    canRead;
-               private bool                    hasRows;
-
-               /* 
-                * Keep track of the connection in order to implement the
-                * CommandBehavior.CloseConnection flag. A null reference means
-                * normal behavior (do not automatically close).
-                */
-               private MySqlConnection connection = null;
-
-               /*
-                * Because the user should not be able to directly create a 
-                * DataReader object, the constructors are
-                * marked as internal.
-                */
-               internal MySqlDataReader( MySqlCommand cmd, CommandBehavior behavior)
-               {
-                       this.command = cmd;
-                       connection = (MySqlConnection)command.Connection;
-                       commandBehavior = behavior;
-               }
-
-               /// <summary>
-               /// Gets a value indicating the depth of nesting for the current row.  This method is not 
-               /// supported currently and always returns 0.
-               /// </summary>
-               public int Depth 
-               {
-                       get { return 0;  }
-               }
-
-               /// <summary>
-               /// Gets a value indicating whether the data reader is closed.
-               /// </summary>
-               public bool IsClosed
-               {
-                       get  { return ! isOpen; }
-               }
-
-               void IDisposable.Dispose() 
-               {
-                       if (isOpen)
-                               Close();
-               }
-
-               /// <summary>
-               /// Gets the number of rows changed, inserted, or deleted by execution of the SQL statement.
-               /// </summary>
-               public int RecordsAffected 
-               {
-                       // RecordsAffected returns the number of rows affected in batch
-                       // statments from insert/delete/update statments.  This property
-                       // is not completely accurate until .Close() has been called.
-                       get { return command.UpdateCount; }
-               }
-
-               /// <summary>
-               /// Gets a value indicating whether the MySqlDataReader contains one or more rows.
-               /// </summary>
-               public bool HasRows
-               {
-                       get { return hasRows; }
-               }
-
-               /// <summary>
-               /// Closes the MySqlDataReader object.
-               /// </summary>
-               public void Close()
-               {
-                       // finish any current command
-                       ClearCurrentResult();
-                       command.ExecuteBatch(false);
-                       connection.InternalConnection.Driver.ClearPeekedPacket();
-
-                       connection.Reader = null;
-                       if (0 != (commandBehavior & CommandBehavior.CloseConnection))
-                               connection.Close();
-
-                       isOpen = false;
-               }
-
-
-
-
-               /// <summary>
-               /// Gets the number of columns in the current row.
-               /// </summary>
-               public int FieldCount
-               {
-                       // Return the count of the number of columns, which in
-                       // this case is the size of the column metadata
-                       // array.
-                       get 
-                       { 
-                               if (_fields != null)
-                                       return _fields.Length;
-                               return 0;
-                       }
-               }
-
-               /// <summary>
-               /// Overloaded. Gets the value of a column in its native format.
-               /// In C#, this property is the indexer for the MySqlDataReader class.
-               /// </summary>
-               public object this [ int i ]
-               {
-                       get 
-                       {
-                               return this.GetValue(i);
-                       }
-               }
-
-               /// <summary>
-               /// Gets the value of a column in its native format.
-               ///     [C#] In C#, this property is the indexer for the MySqlDataReader class.
-               /// </summary>
-               public object this [ String name ]
-               {
-                       // Look up the ordinal and return 
-                       // the value at that position.
-                       get { return this[GetOrdinal(name)]; }
-               }
-
-               private MySqlField GetField(int i)
-               {
-                       if (i >= _fields.Length) throw new IndexOutOfRangeException();
-                       return _fields[i];
-               }
-
-               #region TypeSafe Accessors
-               /// <summary>
-               /// Gets the value of the specified column as a Boolean.
-               /// </summary>
-               /// <param name="i"></param>
-               /// <returns></returns>
-               public bool GetBoolean(int i)
-               {
-                       return Convert.ToBoolean(GetValue(i));
-               }
-
-               /// <summary>
-               /// Gets the value of the specified column as a byte.
-               /// </summary>
-               /// <param name="i"></param>
-               /// <returns></returns>
-               public byte GetByte(int i)
-               {
-                       return Convert.ToByte(GetValue(i));
-               }
-
-               /// <summary>
-               /// Reads a stream of bytes from the specified column offset into the buffer an array starting at the given buffer offset.
-               /// </summary>
-               /// <param name="i">The zero-based column ordinal. </param>
-               /// <param name="dataIndex">The index within the field from which to begin the read operation. </param>
-               /// <param name="buffer">The buffer into which to read the stream of bytes. </param>
-               /// <param name="bufferIndex">The index for buffer to begin the read operation. </param>
-               /// <param name="length">The maximum length to copy into the buffer. </param>
-               /// <returns>The actual number of bytes read.</returns>
-               public long GetBytes(int i, long dataIndex, byte[] buffer, int bufferIndex, int length)
-               {
-                       if (i >= _fields.Length) 
-                               throw new IndexOutOfRangeException();
-
-                       byte[] bytes = (byte[])GetValue(i);
-
-                       if (buffer == null) 
-                               return bytes.Length;
-
-                       // adjust the length so we don't run off the end
-                       if (bytes.Length < (dataIndex+length)) 
-                       {
-                               length = (int)(bytes.Length - dataIndex);
-                       }
-
-                       for (int x=0; x < length; x++)
-                       {
-                               buffer[bufferIndex+x] = bytes[dataIndex+x];     
-                       }
-
-                       return length;
-               }
-
-               /// <summary>
-               /// Gets the value of the specified column as a single character.
-               /// </summary>
-               /// <param name="i"></param>
-               /// <returns></returns>
-               public char GetChar(int i)
-               {
-                       return Convert.ToChar(GetValue(i));
-               }
-
-               /// <summary>
-               /// Reads a stream of characters from the specified column offset into the buffer as an array starting at the given buffer offset.
-               /// </summary>
-               /// <param name="i"></param>
-               /// <param name="fieldOffset"></param>
-               /// <param name="buffer"></param>
-               /// <param name="bufferoffset"></param>
-               /// <param name="length"></param>
-               /// <returns></returns>
-               public long GetChars(int i, long fieldOffset, char[] buffer, int bufferoffset, int length)
-               {
-                       if (i >= _fields.Length) 
-                               throw new IndexOutOfRangeException();
-
-                       // retrieve the bytes of the column
-                       long bytesize = GetBytes(i, 0, null, 0, 0);
-                       byte[] bytes = new byte[bytesize];
-                       GetBytes(i, 0, bytes, 0, (int)bytesize);
-
-                       char[] chars = System.Text.Encoding.UTF8.GetChars(bytes, 0, (int)bytesize);
-
-                       if (buffer == null) 
-                               return chars.Length;
-
-                       // adjust the length so we don't run off the end
-                       if (chars.Length < (fieldOffset+length)) 
-                       {
-                               length = (int)(chars.Length - fieldOffset);
-                       }
-
-                       for (int x=0; x < length; x++)
-                       {
-                               buffer[bufferoffset+x] = chars[fieldOffset+x];  
-                       }
-
-                       return length;
-               }
-
-               /// <summary>
-               /// Gets the name of the source data type.
-               /// </summary>
-               /// <param name="i"></param>
-               /// <returns></returns>
-               public String GetDataTypeName(int i)
-               {
-                       if (! isOpen) throw new Exception("No current query in data reader");
-                       if (i >= _fields.Length) throw new IndexOutOfRangeException();
-
-                       // return the name of the type used on the backend
-                       return _fields[i].GetFieldTypeName();
-               }
-
-               /// <summary>
-               /// Gets the value of the specified column as a DateTime object.
-               /// </summary>
-               /// <param name="i"></param>
-               /// <returns></returns>
-               public DateTime GetDateTime(int i)
-               {
-                       return Convert.ToDateTime(GetValue(i));
-               }
-
-               /// <summary>
-               /// Gets the value of the specified column as a Decimal object.
-               /// </summary>
-               /// <param name="i"></param>
-               /// <returns></returns>
-               public Decimal GetDecimal(int i)
-               {
-                       return Convert.ToDecimal(GetValue(i));
-               }
-
-               /// <summary>
-               /// Gets the value of the specified column as a double-precision floating point number.
-               /// </summary>
-               /// <param name="i"></param>
-               /// <returns></returns>
-               public double GetDouble(int i)
-               {
-                       return Convert.ToDouble(GetValue(i));
-               }
-
-               /// <summary>
-               /// Gets the Type that is the data type of the object.
-               /// </summary>
-               /// <param name="i"></param>
-               /// <returns></returns>
-               public Type GetFieldType(int i)
-               {
-                       if (! isOpen) throw new Exception("No current query in data reader");
-                       if (i >= _fields.Length) throw new IndexOutOfRangeException();
-
-                       return _fields[i].GetFieldType();
-               }
-
-               /// <summary>
-               /// Gets the value of the specified column as a single-precision floating point number.
-               /// </summary>
-               /// <param name="i"></param>
-               /// <returns></returns>
-               public float GetFloat(int i)
-               {
-                       return Convert.ToSingle(GetValue(i));
-               }
-
-               /// <summary>
-               /// Gets the value of the specified column as a globally-unique identifier (GUID).
-               /// This is currently not supported.
-               /// </summary>
-               /// <param name="i"></param>
-               /// <returns></returns>
-               public Guid GetGuid(int i)
-               {
-                       /*
-                       * Force the cast to return the type. InvalidCastException
-                       * should be thrown if the data is not already of the correct type.
-                       */
-                       // The sample does not support this method.
-                       throw new NotSupportedException("GetGUID not supported.");
-               }
-
-               /// <summary>
-               /// Gets the value of the specified column as a 16-bit signed integer.
-               /// </summary>
-               /// <param name="i"></param>
-               /// <returns></returns>
-               public Int16 GetInt16(int i)
-               {
-                       return Convert.ToInt16(GetValue(i));
-               }
-
-               /// <summary>
-               /// Gets the value of the specified column as a 32-bit signed integer.
-               /// </summary>
-               /// <param name="i"></param>
-               /// <returns></returns>
-               public Int32 GetInt32(int i)
-               {
-                       return Convert.ToInt32(GetValue(i));
-               }
-
-               /// <summary>
-               /// Gets the value of the specified column as a 64-bit signed integer.
-               /// </summary>
-               /// <param name="i"></param>
-               /// <returns></returns>
-               public Int64 GetInt64(int i)
-               {
-                       return Convert.ToInt64(GetValue(i));
-               }
-
-               /// <summary>
-               /// Gets the name of the specified column.
-               /// </summary>
-               /// <param name="i"></param>
-               /// <returns></returns>
-               public String GetName(int i)
-               {
-                       return _fields[i].ColumnName;
-               }
-
-               /// <summary>
-               /// Gets the column ordinal, given the name of the column.
-               /// </summary>
-               /// <param name="name"></param>
-               /// <returns></returns>
-               public int GetOrdinal(string name)
-               {
-                       if (! isOpen)
-                               throw new Exception("No current query in data reader");
-
-                       for (int i=0; i < _fields.Length; i ++) 
-                       {
-                               if (_fields[i].ColumnName.ToLower().Equals(name.ToLower()))
-                                       return i;
-                       }
-
-                       // Throw an exception if the ordinal cannot be found.
-                       throw new IndexOutOfRangeException("Could not find specified column in results");
-               }
-
-               /// <summary>
-               /// Returns a DataTable that describes the column metadata of the MySqlDataReader.
-               /// </summary>
-               /// <returns></returns>
-               public DataTable GetSchemaTable()
-               {
-                       // Only Results from SQL SELECT Queries 
-                       // get a DataTable for schema of the result
-                       // otherwise, DataTable is null reference
-                       if (_fields.Length == 0) return null;
-
-                       DataTable dataTableSchema = new DataTable ("SchemaTable");
-                       
-                       dataTableSchema.Columns.Add ("ColumnName", typeof (string));
-                       dataTableSchema.Columns.Add ("ColumnOrdinal", typeof (int));
-                       dataTableSchema.Columns.Add ("ColumnSize", typeof (int));
-                       dataTableSchema.Columns.Add ("NumericPrecision", typeof (int));
-                       dataTableSchema.Columns.Add ("NumericScale", typeof (int));
-                       dataTableSchema.Columns.Add ("IsUnique", typeof (bool));
-                       dataTableSchema.Columns.Add ("IsKey", typeof (bool));
-                       DataColumn dc = dataTableSchema.Columns["IsKey"];
-                       dc.AllowDBNull = true; // IsKey can have a DBNull
-                       dataTableSchema.Columns.Add ("BaseCatalogName", typeof (string));
-                       dataTableSchema.Columns.Add ("BaseColumnName", typeof (string));
-                       dataTableSchema.Columns.Add ("BaseSchemaName", typeof (string));
-                       dataTableSchema.Columns.Add ("BaseTableName", typeof (string));
-                       dataTableSchema.Columns.Add ("DataType", typeof(Type));
-                       dataTableSchema.Columns.Add ("AllowDBNull", typeof (bool));
-                       dataTableSchema.Columns.Add ("ProviderType", typeof (int));
-                       dataTableSchema.Columns.Add ("IsAliased", typeof (bool));
-                       dataTableSchema.Columns.Add ("IsExpression", typeof (bool));
-                       dataTableSchema.Columns.Add ("IsIdentity", typeof (bool));
-                       dataTableSchema.Columns.Add ("IsAutoIncrement", typeof (bool));
-                       dataTableSchema.Columns.Add ("IsRowVersion", typeof (bool));
-                       dataTableSchema.Columns.Add ("IsHidden", typeof (bool));
-                       dataTableSchema.Columns.Add ("IsLong", typeof (bool));
-                       dataTableSchema.Columns.Add ("IsReadOnly", typeof (bool));
-
-                       int ord = 1;
-                       foreach (MySqlField f in _fields)
-                       {
-                               DataRow r = dataTableSchema.NewRow();
-                               r["ColumnName"] = f.ColumnName;
-                               r["ColumnOrdinal"] = ord++;
-                               r["ColumnSize"] = f.ColumnLength;
-                               int prec = f.NumericPrecision();
-                               int pscale = f.NumericScale();
-                               if (prec != -1)
-                                       r["NumericPrecision"] = (short)prec;
-                               if (pscale != -1)
-                                       r["NumericScale"] = (short)pscale;
-                               r["DataType"] = f.GetFieldType();
-                               r["ProviderType"] = (int)f.GetMySqlDbType();
-                               r["IsLong"] = f.IsBlob() && f.ColumnLength > 255;
-                               r["AllowDBNull"] = f.AllowsNull();
-                               r["IsReadOnly"] = false;
-                               r["IsRowVersion"] = false;
-                               r["IsUnique"] = f.IsUnique();
-                               r["IsKey"] = f.IsPrimaryKey();
-                               r["IsAutoIncrement"] = f.IsAutoIncrement();
-                               r["BaseSchemaName"] = null;
-                               r["BaseCatalogName"] = null;
-                               r["BaseTableName"] = f.TableName;
-                               r["BaseColumnName"] = f.ColumnName;
-
-                               dataTableSchema.Rows.Add( r );
-                       }
-
-                       return dataTableSchema;
-               }
-
-               /// <summary>
-               /// Gets the value of the specified column as a string.
-               /// </summary>
-               /// <param name="i"></param>
-               /// <returns></returns>
-               public String GetString(int i)
-               {
-                       return GetValue(i).ToString();
-               }
-
-               /// <summary>
-               /// Gets the value of the specified column in its native format.
-               /// </summary>
-               /// <param name="i"></param>
-               /// <returns></returns>
-               public object GetValue(int i)
-               {
-                       if (! isOpen) throw new Exception("No current query in data reader");
-                       if (i >= _fields.Length) throw new IndexOutOfRangeException();
-
-                       return _fields[i].GetValue();
-               }
-
-               /// <summary>
-               /// Gets all attribute columns in the collection for the current row.
-               /// </summary>
-               /// <param name="values"></param>
-               /// <returns></returns>
-               public int GetValues(object[] values)
-               {
-                       for (int i=0; i < _fields.Length; i ++) 
-                       {
-                               values[i] = GetValue(i);
-                       }
-
-                       return 0;
-               }
-
-
-               /// <summary>
-               /// Gets the value of the specified column as a 16-bit unsigned integer.
-               /// </summary>
-               /// <param name="i"></param>
-               /// <returns></returns>
-               public UInt16 GetUInt16( int i )
-               {
-                       return Convert.ToUInt16(GetValue(i));
-               }
-
-               /// <summary>
-               /// Gets the value of the specified column as a 32-bit unsigned integer.
-               /// </summary>
-               /// <param name="i"></param>
-               /// <returns></returns>
-               public UInt32 GetUInt32( int i )
-               {
-                       return Convert.ToUInt32(GetValue(i));
-               }
-
-               /// <summary>
-               /// Gets the value of the specified column as a 64-bit unsigned integer.
-               /// </summary>
-               /// <param name="i"></param>
-               /// <returns></returns>
-               public UInt64 GetUInt64( int i )
-               {
-                       return Convert.ToUInt64(GetValue(i));
-               }
-
-
-               #endregion
-
-               IDataReader IDataRecord.GetData(int i)
-               {
-                       throw new NotSupportedException("GetData not supported.");
-               }
-
-               /// <summary>
-               /// Gets a value indicating whether the column contains non-existent or missing values.
-               /// </summary>
-               /// <param name="i"></param>
-               /// <returns></returns>
-               public bool IsDBNull(int i)
-               {
-                       return DBNull.Value == GetValue(i);
-               }
-
-               /// <summary>
-               /// Advances the data reader to the next result, when reading the results of batch SQL statements.
-               /// </summary>
-               /// <returns></returns>
-               public bool NextResult()
-               {
-                       if (! isOpen)
-                               throw new MySqlException("Invalid attempt to NextResult when reader is closed.");
-
-                       Driver driver = connection.InternalConnection.Driver;
-
-                       // clear any rows that have not been read from the last rowset
-                       ClearCurrentResult();
-
-                       // tell our command to continue execution of the SQL batch until it its
-                       // another resultset
-                       Packet packet = command.ExecuteBatch(true);
-
-                       // if there was no more resultsets, then signal done
-                       if (packet == null) 
-                       {
-                               canRead = false;
-                               return false;
-                       }
-
-                       // When executing query statements, the result byte that is returned
-                       // from MySql is the column count.  That is why we reference the LastResult
-                       // property here to dimension our field array
-                       connection.SetState( ConnectionState.Fetching );
-                       
-                       _fields = new MySqlField[ packet.ReadLenInteger() ];
-                       for (int x=0; x < _fields.Length; x++) 
-                       {
-                               packet = driver.ReadPacket();
-                               _fields[x] = new MySqlField();
-                               _fields[x].ReadSchemaInfo( packet );
-                       }
-
-                       // read off the end of schema packet
-                       packet = driver.ReadPacket();
-                       if ( ! packet.IsLastPacket())
-                               throw new MySqlException("Expected end of schema packet");
-
-                       // now take a quick peek at the next packet to see if we have rows
-                       // 
-                       packet = driver.PeekPacket();
-                       hasRows = ! packet.IsLastPacket();
-                       canRead = hasRows;
-
-                       connection.SetState( ConnectionState.Open );
-                       return true;
-               }
-
-               /// <summary>
-               /// Advances the MySqlDataReader to the next record.
-               /// </summary>
-               /// <returns></returns>
-               public bool Read()
-               {
-                       if (! isOpen)
-                               throw new MySqlException("Invalid attempt to Read when reader is closed.");
-
-                       if (! canRead) return false;
-
-                       Driver driver = connection.InternalConnection.Driver;
-                       connection.SetState( ConnectionState.Fetching );
-
-                       try 
-                       {
-                               Packet rowPacket = driver.ReadPacket();
-                               if (rowPacket.IsLastPacket())
-                               {
-                                       canRead = false;
-                                       return false;
-                               }
-                               rowPacket.Position = 0;
-
-                               for (int col=0; col < _fields.Length; col++)
-                               {
-                                       _fields[col].SetValueData( rowPacket, driver.Encoding );
-                               }
-                       }
-                       catch (Exception ex)
-                       {
-                               System.Diagnostics.Trace.WriteLine("MySql error: " + ex.Message);
-                               throw ex;
-                       }
-                       finally 
-                       {
-                               connection.SetState( ConnectionState.Open );
-                       }
-                       return true;
-               }
-
-
-               /*
-               * Implementation specific methods.
-               */
-               private int _cultureAwareCompare(string strA, string strB)
-               {
-       //      return CultureInfo.CurrentCulture.CompareInfo.Compare(strA, strB, CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase);
-                       return 0;
-               }
-
-               #region Private Methods
-
-               private void ClearCurrentResult() 
-               {
-                       if (! canRead) return;
-
-                       Driver driver = connection.InternalConnection.Driver;
-
-                       Packet packet = driver.ReadPacket();
-                       // clean out any current resultset
-                       while (! packet.IsLastPacket())
-                               packet = driver.ReadPacket();
-               }
-
-               #endregion
-
-               #region IEnumerator
-               IEnumerator     IEnumerable.GetEnumerator()
-               {
-                       return new System.Data.Common.DbEnumerator(this);
-               }
-               #endregion
-  }
-}
+// ByteFX.Data data access components for .Net\r
+// Copyright (C) 2002-2003  ByteFX, Inc.\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License, or (at your option) any later version.\r
+// \r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+// Lesser General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+\r
+using System;\r
+using System.Data;\r
+using System.Collections;\r
+\r
+namespace ByteFX.Data.MySqlClient\r
+{\r
+       /// <summary>\r
+       /// Provides a means of reading a forward-only stream of rows from a MySQL database. This class cannot be inherited.\r
+       /// </summary>\r
+       /// <include file='docs/MySqlDataReader.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>\r
+       public sealed class MySqlDataReader : MarshalByRefObject, IEnumerable, IDataReader, IDisposable, IDataRecord\r
+       {\r
+               // The DataReader should always be open when returned to the user.\r
+               private bool                    isOpen = true;\r
+\r
+               // Keep track of the results and position\r
+               // within the resultset (starts prior to first record).\r
+               private MySqlField[]    _fields;\r
+               private CommandBehavior commandBehavior;\r
+               private MySqlCommand    command;\r
+               private bool                    canRead;\r
+               private bool                    hasRows;\r
+               private CommandResult   currentResult;\r
+\r
+               /* \r
+                * Keep track of the connection in order to implement the\r
+                * CommandBehavior.CloseConnection flag. A null reference means\r
+                * normal behavior (do not automatically close).\r
+                */\r
+               private MySqlConnection connection = null;\r
+\r
+               /*\r
+                * Because the user should not be able to directly create a \r
+                * DataReader object, the constructors are\r
+                * marked as internal.\r
+                */\r
+               internal MySqlDataReader( MySqlCommand cmd, CommandBehavior behavior)\r
+               {\r
+                       this.command = cmd;\r
+                       connection = (MySqlConnection)command.Connection;\r
+                       commandBehavior = behavior;\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets a value indicating the depth of nesting for the current row.  This method is not \r
+               /// supported currently and always returns 0.\r
+               /// </summary>\r
+               public int Depth \r
+               {\r
+                       get { return 0;  }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets a value indicating whether the data reader is closed.\r
+               /// </summary>\r
+               public bool IsClosed\r
+               {\r
+                       get  { return ! isOpen; }\r
+               }\r
+\r
+               void IDisposable.Dispose() \r
+               {\r
+                       if (isOpen)\r
+                               Close();\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the number of rows changed, inserted, or deleted by execution of the SQL statement.\r
+               /// </summary>\r
+               public int RecordsAffected \r
+               {\r
+                       // RecordsAffected returns the number of rows affected in batch\r
+                       // statments from insert/delete/update statments.  This property\r
+                       // is not completely accurate until .Close() has been called.\r
+                       get { return command.UpdateCount; }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets a value indicating whether the MySqlDataReader contains one or more rows.\r
+               /// </summary>\r
+               public bool HasRows\r
+               {\r
+                       get { return hasRows; }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Closes the MySqlDataReader object.\r
+               /// </summary>\r
+               public void Close()\r
+               {\r
+                       if (! isOpen) return;\r
+\r
+                       // finish any current command\r
+                       if (currentResult != null)\r
+                               currentResult.Clear();\r
+                       command.ExecuteBatch(false);\r
+\r
+                       connection.Reader = null;\r
+                       if (0 != (commandBehavior & CommandBehavior.CloseConnection))\r
+                               connection.Close();\r
+\r
+                       isOpen = false;\r
+               }\r
+\r
+\r
+\r
+\r
+               /// <summary>\r
+               /// Gets the number of columns in the current row.\r
+               /// </summary>\r
+               public int FieldCount\r
+               {\r
+                       // Return the count of the number of columns, which in\r
+                       // this case is the size of the column metadata\r
+                       // array.\r
+                       get \r
+                       { \r
+                               if (_fields != null)\r
+                                       return _fields.Length;\r
+                               return 0;\r
+                       }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Overloaded. Gets the value of a column in its native format.\r
+               /// In C#, this property is the indexer for the MySqlDataReader class.\r
+               /// </summary>\r
+               public object this [ int i ]\r
+               {\r
+                       get \r
+                       {\r
+                               return this.GetValue(i);\r
+                       }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the value of a column in its native format.\r
+               ///     [C#] In C#, this property is the indexer for the MySqlDataReader class.\r
+               /// </summary>\r
+               public object this [ String name ]\r
+               {\r
+                       // Look up the ordinal and return \r
+                       // the value at that position.\r
+                       get { return this[GetOrdinal(name)]; }\r
+               }\r
+\r
+               private MySqlField GetField(int i)\r
+               {\r
+                       if (i >= _fields.Length) throw new IndexOutOfRangeException();\r
+                       return _fields[i];\r
+               }\r
+\r
+               #region TypeSafe Accessors\r
+               /// <summary>\r
+               /// Gets the value of the specified column as a Boolean.\r
+               /// </summary>\r
+               /// <param name="i"></param>\r
+               /// <returns></returns>\r
+               public bool GetBoolean(int i)\r
+               {\r
+                       return Convert.ToBoolean(GetValue(i));\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the value of the specified column as a byte.\r
+               /// </summary>\r
+               /// <param name="i"></param>\r
+               /// <returns></returns>\r
+               public byte GetByte(int i)\r
+               {\r
+                       return Convert.ToByte(GetValue(i));\r
+               }\r
+\r
+               /// <summary>\r
+               /// Reads a stream of bytes from the specified column offset into the buffer an array starting at the given buffer offset.\r
+               /// </summary>\r
+               /// <param name="i">The zero-based column ordinal. </param>\r
+               /// <param name="dataIndex">The index within the field from which to begin the read operation. </param>\r
+               /// <param name="buffer">The buffer into which to read the stream of bytes. </param>\r
+               /// <param name="bufferIndex">The index for buffer to begin the read operation. </param>\r
+               /// <param name="length">The maximum length to copy into the buffer. </param>\r
+               /// <returns>The actual number of bytes read.</returns>\r
+               public long GetBytes(int i, long dataIndex, byte[] buffer, int bufferIndex, int length)\r
+               {\r
+                       if (i >= _fields.Length) \r
+                               throw new IndexOutOfRangeException();\r
+\r
+                       long bufLen = _fields[i].BufferLength;\r
+\r
+                       if (buffer == null) \r
+                               return bufLen;\r
+\r
+                       if (bufferIndex >= buffer.Length || bufferIndex < 0)\r
+                               throw new IndexOutOfRangeException("Buffer index must be a valid index in buffer");\r
+                       if (buffer.Length < (bufferIndex + length))\r
+                               throw new ArgumentException( "Buffer is not large enough to hold the requested data" );\r
+                       if (dataIndex < 0 || dataIndex >= bufLen )\r
+                               throw new IndexOutOfRangeException( "Data index must be a valid index in the field" );\r
+\r
+                       byte[] bytes = _fields[i].Buffer;\r
+                       long fieldIndex = _fields[i].BufferIndex;\r
+\r
+                       // adjust the length so we don't run off the end\r
+                       if ( bufLen < (dataIndex+length)) \r
+                       {\r
+                               length = (int)((long)bytes.Length - dataIndex);\r
+                       }\r
+\r
+                       for (long x=0; x < length; x++)\r
+                       {\r
+                               buffer[bufferIndex+x] = bytes[fieldIndex+dataIndex+x];  \r
+                       }\r
+\r
+                       return length;\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the value of the specified column as a single character.\r
+               /// </summary>\r
+               /// <param name="i"></param>\r
+               /// <returns></returns>\r
+               public char GetChar(int i)\r
+               {\r
+                       return Convert.ToChar(GetValue(i));\r
+               }\r
+\r
+               /// <summary>\r
+               /// Reads a stream of characters from the specified column offset into the buffer as an array starting at the given buffer offset.\r
+               /// </summary>\r
+               /// <param name="i"></param>\r
+               /// <param name="fieldOffset"></param>\r
+               /// <param name="buffer"></param>\r
+               /// <param name="bufferoffset"></param>\r
+               /// <param name="length"></param>\r
+               /// <returns></returns>\r
+               public long GetChars(int i, long fieldOffset, char[] buffer, int bufferoffset, int length)\r
+               {\r
+                       if (i >= _fields.Length) \r
+                               throw new IndexOutOfRangeException();\r
+\r
+                       // retrieve the bytes of the column\r
+                       long bytesize = GetBytes(i, 0, null, 0, 0);\r
+                       byte[] bytes = new byte[bytesize];\r
+                       GetBytes(i, 0, bytes, 0, (int)bytesize);\r
+\r
+                       char[] chars = System.Text.Encoding.UTF8.GetChars(bytes, 0, (int)bytesize);\r
+\r
+                       if (buffer == null) \r
+                               return chars.Length;\r
+\r
+                       // adjust the length so we don't run off the end\r
+                       if (chars.Length < (fieldOffset+length)) \r
+                       {\r
+                               length = (int)(chars.Length - fieldOffset);\r
+                       }\r
+\r
+                       for (int x=0; x < length; x++)\r
+                       {\r
+                               buffer[bufferoffset+x] = chars[fieldOffset+x];  \r
+                       }\r
+\r
+                       return length;\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the name of the source data type.\r
+               /// </summary>\r
+               /// <param name="i"></param>\r
+               /// <returns></returns>\r
+               public String GetDataTypeName(int i)\r
+               {\r
+                       if (! isOpen) throw new Exception("No current query in data reader");\r
+                       if (i >= _fields.Length) throw new IndexOutOfRangeException();\r
+\r
+                       // return the name of the type used on the backend\r
+                       return _fields[i].GetFieldTypeName();\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the value of the specified column as a DateTime object.\r
+               /// </summary>\r
+               /// <param name="i"></param>\r
+               /// <returns></returns>\r
+               public DateTime GetDateTime(int i)\r
+               {\r
+                       return Convert.ToDateTime(GetValue(i));\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the value of the specified column as a Decimal object.\r
+               /// </summary>\r
+               /// <param name="i"></param>\r
+               /// <returns></returns>\r
+               public Decimal GetDecimal(int i)\r
+               {\r
+                       return Convert.ToDecimal(GetValue(i));\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the value of the specified column as a double-precision floating point number.\r
+               /// </summary>\r
+               /// <param name="i"></param>\r
+               /// <returns></returns>\r
+               public double GetDouble(int i)\r
+               {\r
+                       return Convert.ToDouble(GetValue(i));\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the Type that is the data type of the object.\r
+               /// </summary>\r
+               /// <param name="i"></param>\r
+               /// <returns></returns>\r
+               public Type GetFieldType(int i)\r
+               {\r
+                       if (! isOpen) throw new Exception("No current query in data reader");\r
+                       if (i >= _fields.Length) throw new IndexOutOfRangeException();\r
+\r
+                       return _fields[i].GetFieldType();\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the value of the specified column as a single-precision floating point number.\r
+               /// </summary>\r
+               /// <param name="i"></param>\r
+               /// <returns></returns>\r
+               public float GetFloat(int i)\r
+               {\r
+                       return Convert.ToSingle(GetValue(i));\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the value of the specified column as a globally-unique identifier (GUID).\r
+               /// This is currently not supported.\r
+               /// </summary>\r
+               /// <param name="i"></param>\r
+               /// <returns></returns>\r
+               public Guid GetGuid(int i)\r
+               {\r
+                       return new Guid( GetString(i) );\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the value of the specified column as a 16-bit signed integer.\r
+               /// </summary>\r
+               /// <param name="i"></param>\r
+               /// <returns></returns>\r
+               public Int16 GetInt16(int i)\r
+               {\r
+                       return Convert.ToInt16(GetValue(i));\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the value of the specified column as a 32-bit signed integer.\r
+               /// </summary>\r
+               /// <param name="i"></param>\r
+               /// <returns></returns>\r
+               public Int32 GetInt32(int i)\r
+               {\r
+                       return Convert.ToInt32(GetValue(i));\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the value of the specified column as a 64-bit signed integer.\r
+               /// </summary>\r
+               /// <param name="i"></param>\r
+               /// <returns></returns>\r
+               public Int64 GetInt64(int i)\r
+               {\r
+                       return Convert.ToInt64(GetValue(i));\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the name of the specified column.\r
+               /// </summary>\r
+               /// <param name="i"></param>\r
+               /// <returns></returns>\r
+               public String GetName(int i)\r
+               {\r
+                       return _fields[i].ColumnName;\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the column ordinal, given the name of the column.\r
+               /// </summary>\r
+               /// <param name="name"></param>\r
+               /// <returns></returns>\r
+               public int GetOrdinal(string name)\r
+               {\r
+                       if (! isOpen)\r
+                               throw new Exception("No current query in data reader");\r
+\r
+                       for (int i=0; i < _fields.Length; i ++) \r
+                       {\r
+                               if (_fields[i].ColumnName.ToLower().Equals(name.ToLower()))\r
+                                       return i;\r
+                       }\r
+\r
+                       // Throw an exception if the ordinal cannot be found.\r
+                       throw new IndexOutOfRangeException("Could not find specified column in results");\r
+               }\r
+\r
+               /// <summary>\r
+               /// Returns a DataTable that describes the column metadata of the MySqlDataReader.\r
+               /// </summary>\r
+               /// <returns></returns>\r
+               public DataTable GetSchemaTable()\r
+               {\r
+                       // Only Results from SQL SELECT Queries \r
+                       // get a DataTable for schema of the result\r
+                       // otherwise, DataTable is null reference\r
+                       if (_fields.Length == 0) return null;\r
+\r
+                       DataTable dataTableSchema = new DataTable ("SchemaTable");\r
+                       \r
+                       dataTableSchema.Columns.Add ("ColumnName", typeof (string));\r
+                       dataTableSchema.Columns.Add ("ColumnOrdinal", typeof (int));\r
+                       dataTableSchema.Columns.Add ("ColumnSize", typeof (int));\r
+                       dataTableSchema.Columns.Add ("NumericPrecision", typeof (int));\r
+                       dataTableSchema.Columns.Add ("NumericScale", typeof (int));\r
+                       dataTableSchema.Columns.Add ("IsUnique", typeof (bool));\r
+                       dataTableSchema.Columns.Add ("IsKey", typeof (bool));\r
+                       DataColumn dc = dataTableSchema.Columns["IsKey"];\r
+                       dc.AllowDBNull = true; // IsKey can have a DBNull\r
+                       dataTableSchema.Columns.Add ("BaseCatalogName", typeof (string));\r
+                       dataTableSchema.Columns.Add ("BaseColumnName", typeof (string));\r
+                       dataTableSchema.Columns.Add ("BaseSchemaName", typeof (string));\r
+                       dataTableSchema.Columns.Add ("BaseTableName", typeof (string));\r
+                       dataTableSchema.Columns.Add ("DataType", typeof(Type));\r
+                       dataTableSchema.Columns.Add ("AllowDBNull", typeof (bool));\r
+                       dataTableSchema.Columns.Add ("ProviderType", typeof (int));\r
+                       dataTableSchema.Columns.Add ("IsAliased", typeof (bool));\r
+                       dataTableSchema.Columns.Add ("IsExpression", typeof (bool));\r
+                       dataTableSchema.Columns.Add ("IsIdentity", typeof (bool));\r
+                       dataTableSchema.Columns.Add ("IsAutoIncrement", typeof (bool));\r
+                       dataTableSchema.Columns.Add ("IsRowVersion", typeof (bool));\r
+                       dataTableSchema.Columns.Add ("IsHidden", typeof (bool));\r
+                       dataTableSchema.Columns.Add ("IsLong", typeof (bool));\r
+                       dataTableSchema.Columns.Add ("IsReadOnly", typeof (bool));\r
+\r
+                       int ord = 1;\r
+                       foreach (MySqlField f in _fields)\r
+                       {\r
+                               DataRow r = dataTableSchema.NewRow();\r
+                               r["ColumnName"] = f.ColumnName;\r
+                               r["ColumnOrdinal"] = ord++;\r
+                               r["ColumnSize"] = f.ColumnLength;\r
+                               int prec = f.NumericPrecision;\r
+                               int pscale = f.NumericScale;\r
+                               if (prec != -1)\r
+                                       r["NumericPrecision"] = (short)prec;\r
+                               if (pscale != -1)\r
+                                       r["NumericScale"] = (short)pscale;\r
+                               r["DataType"] = f.GetFieldType();\r
+                               r["ProviderType"] = (int)f.Type;\r
+                               r["IsLong"] = f.IsBlob() && f.ColumnLength > 255;\r
+                               r["AllowDBNull"] = f.AllowsNull();\r
+                               r["IsReadOnly"] = false;\r
+                               r["IsRowVersion"] = false;\r
+                               r["IsUnique"] = f.IsUnique();\r
+                               r["IsKey"] = f.IsPrimaryKey();\r
+                               r["IsAutoIncrement"] = f.IsAutoIncrement();\r
+                               r["BaseSchemaName"] = null;\r
+                               r["BaseCatalogName"] = null;\r
+                               r["BaseTableName"] = f.TableName;\r
+                               r["BaseColumnName"] = f.ColumnName;\r
+\r
+                               dataTableSchema.Rows.Add( r );\r
+                       }\r
+\r
+                       return dataTableSchema;\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the value of the specified column as a string.\r
+               /// </summary>\r
+               /// <param name="i"></param>\r
+               /// <returns></returns>\r
+               public String GetString(int i)\r
+               {\r
+                       return GetValue(i).ToString();\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the value of the specified column in its native format.\r
+               /// </summary>\r
+               /// <param name="i"></param>\r
+               /// <returns></returns>\r
+               public object GetValue(int i)\r
+               {\r
+                       if (! isOpen) throw new Exception("No current query in data reader");\r
+                       if (i >= _fields.Length) throw new IndexOutOfRangeException();\r
+\r
+                       return _fields[i].GetValue();\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets all attribute columns in the collection for the current row.\r
+               /// </summary>\r
+               /// <param name="values"></param>\r
+               /// <returns></returns>\r
+               public int GetValues(object[] values)\r
+               {\r
+                       for (int i=0; i < _fields.Length; i ++) \r
+                       {\r
+                               values[i] = GetValue(i);\r
+                       }\r
+\r
+                       return 0;\r
+               }\r
+\r
+\r
+               /// <summary>\r
+               /// Gets the value of the specified column as a 16-bit unsigned integer.\r
+               /// </summary>\r
+               /// <param name="i"></param>\r
+               /// <returns></returns>\r
+               public UInt16 GetUInt16( int i )\r
+               {\r
+                       return Convert.ToUInt16(GetValue(i));\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the value of the specified column as a 32-bit unsigned integer.\r
+               /// </summary>\r
+               /// <param name="i"></param>\r
+               /// <returns></returns>\r
+               public UInt32 GetUInt32( int i )\r
+               {\r
+                       return Convert.ToUInt32(GetValue(i));\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the value of the specified column as a 64-bit unsigned integer.\r
+               /// </summary>\r
+               /// <param name="i"></param>\r
+               /// <returns></returns>\r
+               public UInt64 GetUInt64( int i )\r
+               {\r
+                       return Convert.ToUInt64(GetValue(i));\r
+               }\r
+\r
+\r
+               #endregion\r
+\r
+               IDataReader IDataRecord.GetData(int i)\r
+               {\r
+                       throw new NotSupportedException("GetData not supported.");\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets a value indicating whether the column contains non-existent or missing values.\r
+               /// </summary>\r
+               /// <param name="i"></param>\r
+               /// <returns></returns>\r
+               public bool IsDBNull(int i)\r
+               {\r
+                       return DBNull.Value == GetValue(i);\r
+               }\r
+\r
+               /// <summary>\r
+               /// Advances the data reader to the next result, when reading the results of batch SQL statements.\r
+               /// </summary>\r
+               /// <returns></returns>\r
+               public bool NextResult()\r
+               {\r
+                       if (! isOpen)\r
+                               throw new MySqlException("Invalid attempt to NextResult when reader is closed.");\r
+\r
+                       // clear any rows that have not been read from the last rowset\r
+                       if (currentResult != null)\r
+                               currentResult.Clear();\r
+\r
+                       // tell our command to continue execution of the SQL batch until it its\r
+                       // another resultset\r
+                       currentResult = command.ExecuteBatch(true);\r
+\r
+                       // if there was no more resultsets, then signal done\r
+                       if (currentResult == null) \r
+                       {\r
+                               canRead = false;\r
+                               return false;\r
+                       }\r
+\r
+                       // When executing query statements, the result byte that is returned\r
+                       // from MySql is the column count.  That is why we reference the LastResult\r
+                       // property here to dimension our field array\r
+                       connection.SetState( ConnectionState.Fetching );\r
+                       \r
+                       _fields = new MySqlField[ currentResult.ColumnCount ];\r
+                       for (int x=0; x < _fields.Length; x++) \r
+                               _fields[x] = currentResult.GetField();\r
+\r
+                       hasRows = currentResult.CheckForRows();\r
+                       canRead = hasRows;                      \r
+\r
+                       connection.SetState( ConnectionState.Open );\r
+                       return true;\r
+               }\r
+\r
+               /// <summary>\r
+               /// Advances the MySqlDataReader to the next record.\r
+               /// </summary>\r
+               /// <returns></returns>\r
+               public bool Read()\r
+               {\r
+                       if (! isOpen)\r
+                               throw new MySqlException("Invalid attempt to Read when reader is closed.");\r
+\r
+                       if (! canRead) return false;\r
+\r
+                       Driver driver = connection.InternalConnection.Driver;\r
+                       connection.SetState( ConnectionState.Fetching );\r
+\r
+                       try \r
+                       {\r
+                               if (! currentResult.ReadDataRow())\r
+                               {\r
+                                       canRead = false;\r
+                                       return false;\r
+                               }\r
+\r
+                               for (int col=0; col < _fields.Length; col++)\r
+                               {\r
+                                       byte[] buf = currentResult.GetFieldBuffer();\r
+                                       int index = currentResult.GetFieldIndex();\r
+                                       long len = currentResult.GetFieldLength();\r
+                                       _fields[col].SetValueData( buf, index, len, driver.Version );\r
+                                       currentResult.NextField();\r
+                               }\r
+                       }\r
+                       catch (Exception ex)\r
+                       {\r
+                               System.Diagnostics.Trace.WriteLine("MySql error: " + ex.Message);\r
+                               throw ex;\r
+                       }\r
+                       finally \r
+                       {\r
+                               connection.SetState( ConnectionState.Open );\r
+                       }\r
+                       return true;\r
+               }\r
+\r
+\r
+               /*\r
+               * Implementation specific methods.\r
+               */\r
+               private int _cultureAwareCompare(string strA, string strB)\r
+               {\r
+       //      return CultureInfo.CurrentCulture.CompareInfo.Compare(strA, strB, CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase);\r
+                       return 0;\r
+               }\r
+\r
+\r
+               #region IEnumerator\r
+               IEnumerator     IEnumerable.GetEnumerator()\r
+               {\r
+                       return new System.Data.Common.DbEnumerator(this);\r
+               }\r
+               #endregion\r
+  }\r
+}\r
diff --git a/mcs/class/ByteFX.Data/mysqlclient/docs/MySqlCommand.xml b/mcs/class/ByteFX.Data/mysqlclient/docs/MySqlCommand.xml
new file mode 100644 (file)
index 0000000..6944960
--- /dev/null
@@ -0,0 +1,106 @@
+<MyDocs>\r
+<MyMembers name="Class">\r
+<remarks>\r
+<B>MySqlCommand</B> features the following methods for executing commands at a MySQL database:\r
+<list type="table">\r
+       <listheader><term>Item</term><term>Description</term></listheader>\r
+       <item>\r
+               <term><a href="ByteFX.Data.MySqlClient.MySqlCommand.ExecuteReader_overloads.html">ExecuteReader</a></term>\r
+               <description>Executes commands that return rows.</description>\r
+       </item>\r
+       <item>\r
+               <term><a href="ByteFX.Data.MySqlClient.MySqlCommand.ExecuteNonQuery.html">ExecuteNonQuery</a></term>\r
+               <description>Executes commands such as SQL INSERT, DELETE, and UPDATE statements.</description>\r
+       </item>\r
+       <item>\r
+               <term><a href="ByteFX.Data.MySqlClient.MySqlCommand.ExecuteScalar.html">ExecuteScalar</a></term>\r
+               <description>Retrieves a single value (for example, an aggregate value) from a database.</description>\r
+       </item>\r
+</list>\r
+\r
+You can reset the <B>CommandText</B> property and reuse the <B>MySqlCommand</B> \r
+object. However, you must close the <A \r
+href="ByteFX.Data.MySqlClient.MySqlDataReader.html">MySqlDataReader</A> \r
+before you can execute a new or previous command.\r
+\r
+If a <A href="ByteFX.Data.MySqlClient.MySqlException.html">MySqlException</A> is \r
+generated by the method executing a <B>MySqlCommand</B>, the <A \r
+href="ByteFX.Data.MySqlClient.MySqlConnection.html">MySqlConnection</A> \r
+remains open.  It is the responsibility of the programmer to close the connection.\r
+</remarks>\r
+\r
+<example>\r
+       The following example creates a <A href="frlrfsystemdatasqlclientsqlcommandclasstopic.htm">MySqlCommand</A> and \r
+       a <B>MySqlConnection</B>. The <B>MySqlConnection</B> is opened and set as the <A \r
+       href="frlrfsystemdatasqlclientsqlcommandclassconnectiontopic.htm">Connection</A> \r
+       for the <B>MySqlCommand</B>. The example then calls <A \r
+       href="frlrfsystemdatasqlclientsqlcommandclassexecutenonquerytopic.htm">ExecuteNonQuery</A>, \r
+       and closes the connection. To accomplish this, the <B>ExecuteNonQuery</B> is \r
+       passed a connection string and a query string that is a SQL INSERT \r
+       statement.\r
+       <code lang="Visual Basic">\r
+Public Sub InsertRow(myConnectionString As String)\r
+       ' If the connection string is null, use a default.\r
+       If myConnectionString = "" Then\r
+               myConnectionString = "Database=Test;Data Source=localhost;User Id=username;Password=pass"\r
+       End If\r
+       Dim myConnection As New MySqlConnection(myConnectionString)\r
+       Dim myInsertQuery As String = "INSERT INTO Orders (id, customerId, amount) Values(1001, 23, 30.66)"\r
+       Dim myCommand As New MySqlCommand(myInsertQuery)\r
+       myCommand.Connection = myConnection\r
+       myConnection.Open()\r
+       myCommand.ExecuteNonQuery()\r
+       myCommand.Connection.Close()\r
+End Sub\r
+       </code>\r
+       <code lang="C#">\r
+public void InsertRow(string myConnectionString) \r
+{\r
+       // If the connection string is null, use a default.\r
+       if(myConnectionString == "") \r
+       {\r
+               myConnectionString = "Database=Test;Data Source=localhost;User Id=username;Password=pass";\r
+       }\r
+       MySqlConnection myConnection = new MySqlConnection(myConnectionString);\r
+       string myInsertQuery = "INSERT INTO Orders (id, customerId, amount) Values(1001, 23, 30.66)";\r
+       MySqlCommand myCommand = new MySqlCommand(myInsertQuery);\r
+       myCommand.Connection = myConnection;\r
+       myConnection.Open();\r
+       myCommand.ExecuteNonQuery();\r
+       myCommand.Connection.Close();\r
+}\r
+       </code>\r
+</example>\r
+\r
+\r
+</MyMembers>\r
+\r
+<MyMembers name="ConnectionTimeout">\r
+       <exception cref="System.ArgumentException">The value set is less than 0.</exception>\r
+       <remarks>\r
+               A value of 0 indicates no limit, and should be avoided in a \r
+               <a href="ByteFX.Data.MySqlClient.MySqlConnection.ConnectionString.html">ConnectionString</a>\r
+               because an attempt to connect will wait indefinitely.\r
+       </remarks>\r
+       <example>\r
+               The following example creates a MySqlConnection\r
+               and sets some of its properties in the connection string.\r
+               <code lang="Visual Basic"><c>\r
+Public Sub CreateSqlConnection()\r
+       Dim myConnection As New MySqlConnection()\r
+       myConnection.ConnectionString = "Persist Security Info=False;Username=user;Password=pass;database=test1;server=localhost;Connect Timeout=30"\r
+       myConnection.Open()\r
+End Sub\r
+</c></code>\r
+<code lang="C#"><c>\r
+public void CreateSqlConnection() \r
+{\r
+       MySqlConnection myConnection = new MySqlConnection();\r
+       myConnection.ConnectionString = "Persist Security Info=False;Username=user;Password=pass;database=test1;server=localhost;Connect Timeout=30";\r
+       myConnection.Open();\r
+}\r
+</c></code>                            \r
+       </example>\r
+</MyMembers>\r
+\r
+</MyDocs>
\ No newline at end of file
diff --git a/mcs/class/ByteFX.Data/mysqlclient/docs/MySqlCommandBuilder.xml b/mcs/class/ByteFX.Data/mysqlclient/docs/MySqlCommandBuilder.xml
new file mode 100644 (file)
index 0000000..6be31e1
--- /dev/null
@@ -0,0 +1,138 @@
+<MyDocs>\r
+<MyMembers name="Class">\r
+<remarks>\r
+<p>The <A href="frlrfsystemdatasqlclientsqldataadapterclasstopic.htm">MySqlDataAdapter</A> \r
+does not automatically generate the SQL statements required to \r
+reconcile changes made to a <A href="frlrfsystemdatadatasetclasstopic.htm">DataSet</A> with the associated \r
+instance of MySQL. However, you can create a <B>MySqlCommandBuilder</B> \r
+object to automatically generate SQL statements for single-table \r
+updates if you set the <A href="frlrfsystemdatasqlclientsqldataadapterclassselectcommandtopic.htm">SelectCommand</A> \r
+property of the <B>MySqlDataAdapter</B>. Then, any additional SQL \r
+statements that you do not set are generated by the \r
+<B>MySqlCommandBuilder</B>.</p>\r
+<P>The <B>MySqlCommandBuilder</B> registers itself as a listener for <A \r
+href="frlrfsystemdatasqlclientsqldataadapterclassrowupdatingtopic.htm">RowUpdating</A> \r
+events whenever you set the <A \r
+href="frlrfsystemdatasqlclientsqlcommandbuilderclassdataadaptertopic.htm">DataAdapter</A> \r
+property. You can only associate one <B>MySqlDataAdapter</B> or \r
+<B>MySqlCommandBuilder</B> object with each other at one time.</P>\r
+<P>To generate INSERT, UPDATE, or DELETE statements, the \r
+<B>MySqlCommandBuilder</B> uses the <B>SelectCommand</B> property to retrieve a \r
+required set of metadata automatically. If you change the <B>SelectCommand</B> \r
+after the metadata has is retrieved (for example, after the first update), you \r
+should call the <A \r
+href="frlrfsystemdatasqlclientsqlcommandbuilderclassrefreshschematopic.htm">RefreshSchema</A> \r
+method to update the metadata.</P>\r
+<P>The <B>SelectCommand</B> must also return at least one primary key or unique \r
+column. If none are present, an <I>InvalidOperation</I> exception is generated, \r
+and the commands are not generated.</P>\r
+<P>The <B>MySqlCommandBuilder</B> also uses the <A \r
+href="frlrfsystemdatasqlclientsqlcommandclassconnectiontopic.htm">Connection</A>, \r
+<A \r
+href="frlrfsystemdatasqlclientsqlcommandclasscommandtimeouttopic.htm">CommandTimeout</A>, \r
+and <A \r
+href="frlrfsystemdatasqlclientsqlcommandclasstransactiontopic.htm">Transaction</A> \r
+properties referenced by the <B>SelectCommand</B>. The user should call \r
+<B>RefreshSchema</B> if any of these properties are modified, or if the \r
+<B>SelectCommand</B> itself is replaced. Otherwise the <A \r
+href="frlrfsystemdatasqlclientsqldataadapterclassinsertcommandtopic.htm">InsertCommand</A>, \r
+<A \r
+href="frlrfsystemdatasqlclientsqldataadapterclassupdatecommandtopic.htm">UpdateCommand</A>, \r
+and <A \r
+href="frlrfsystemdatasqlclientsqldataadapterclassdeletecommandtopic.htm">DeleteCommand</A> \r
+properties retain their previous values.</P>\r
+<P>If you call <A \r
+href="frlrfsystemcomponentmodelcomponentclassdisposetopic.htm">Dispose</A>, the \r
+<B>MySqlCommandBuilder</B> is disassociated from the <B>MySqlDataAdapter</B>, and \r
+the generated commands are no longer used.</P>\r
+</remarks>\r
+\r
+<example>\r
+       The     following example uses the <A \r
+       href="frlrfsystemdatasqlclientsqlcommandclasstopic.htm">MySqlCommand</A>, along <A \r
+       href="frlrfsystemdatasqlclientsqldataadapterclasstopic.htm">MySqlDataAdapter</A> \r
+       and <A \r
+       href="frlrfsystemdatasqlclientsqlconnectionclasstopic.htm">MySqlConnection</A>, to \r
+       select rows from a data source. The example is passed an initialized <A \r
+       href="frlrfsystemdatadatasetclasstopic.htm">DataSet</A>, a connection string, a \r
+       query string that is a SQL SELECT statement, and a string that is the \r
+       name of the database table. The example then creates a <B>MySqlCommandBuilder</B>.\r
+       \r
+       <code lang="Visual Basic">\r
+Public Shared Function SelectRows(myConnection As String, mySelectQuery As String, myTableName As String) As DataSet\r
+    Dim myConn As New MySqlConnection(myConnection)\r
+    Dim myDataAdapter As New MySqlDataAdapter()\r
+    myDataAdapter.SelectCommand = New MySqlCommand(mySelectQuery, myConn)\r
+    Dim cb As SqlCommandBuilder = New MySqlCommandBuilder(myDataAdapter)\r
+\r
+    myConn.Open()\r
+\r
+    Dim ds As DataSet = New DataSet\r
+    myDataAdapter.Fill(ds, myTableName)\r
+\r
+    ' Code to modify data in DataSet here \r
+\r
+    ' Without the MySqlCommandBuilder this line would fail.\r
+    myDataAdapter.Update(ds, myTableName)\r
+\r
+    myConn.Close()\r
+End Function 'SelectRows\r
+       </code>\r
+       <code lang="C#">\r
+public static DataSet SelectRows(string myConnection, string mySelectQuery, string myTableName)\r
+{\r
+   MySqlConnection myConn = new MySqlConnection(myConnection);\r
+   MySqlDataAdapter myDataAdapter = new MySqlDataAdapter();\r
+   myDataAdapter.SelectCommand = new MySqlCommand(mySelectQuery, myConn);\r
+   MySqlCommandBuilder cb = new MySqlCommandBuilder(myDataAdapter);\r
+\r
+   myConn.Open();\r
+\r
+   DataSet ds = new DataSet();\r
+   myDataAdapter.Fill(ds, myTableName);\r
+\r
+   //code to modify data in DataSet here\r
+\r
+   //Without the MySqlCommandBuilder this line would fail\r
+   myDataAdapter.Update(ds, myTableName);\r
+\r
+   myConn.Close();\r
+\r
+   return ds;\r
+}\r
+\r
+       </code>\r
+</example>\r
+\r
+\r
+</MyMembers>\r
+\r
+<MyMembers name="ConnectionTimeout">\r
+       <exception cref="System.ArgumentException">The value set is less than 0.</exception>\r
+       <remarks>\r
+               A value of 0 indicates no limit, and should be avoided in a \r
+               <a href="ByteFX.Data.MySqlClient.MySqlConnection.ConnectionString.html">ConnectionString</a>\r
+               because an attempt to connect will wait indefinitely.\r
+       </remarks>\r
+       <example>\r
+               The following example creates a MySqlConnection\r
+               and sets some of its properties in the connection string.\r
+               <code lang="Visual Basic"><c>\r
+Public Sub CreateSqlConnection()\r
+       Dim myConnection As New MySqlConnection()\r
+       myConnection.ConnectionString = "Persist Security Info=False;Username=user;Password=pass;database=test1;server=localhost;Connect Timeout=30"\r
+       myConnection.Open()\r
+End Sub\r
+</c></code>\r
+<code lang="C#"><c>\r
+public void CreateSqlConnection() \r
+{\r
+       MySqlConnection myConnection = new MySqlConnection();\r
+       myConnection.ConnectionString = "Persist Security Info=False;Username=user;Password=pass;database=test1;server=localhost;Connect Timeout=30";\r
+       myConnection.Open();\r
+}\r
+</c></code>                            \r
+       </example>\r
+</MyMembers>\r
+\r
+</MyDocs>
\ No newline at end of file
diff --git a/mcs/class/ByteFX.Data/mysqlclient/docs/MySqlConnection.xml b/mcs/class/ByteFX.Data/mysqlclient/docs/MySqlConnection.xml
new file mode 100644 (file)
index 0000000..4ab4da1
--- /dev/null
@@ -0,0 +1,312 @@
+<MyDocs>\r
+<MyMembers name="Class">\r
+<remarks>\r
+       <para>\r
+               A <b>MySqlConnection</b> object represents a session to a MySQL Server \r
+               data source.  When you create an instance of <B>MySqlConnection</B>, all \r
+               properties are set to their initial values. For a list of these values, see the \r
+               <B>MySqlConnection</B> constructor.\r
+       </para>\r
+\r
+       <para>\r
+               If the <B>MySqlConnection</B> goes out of scope, it is not closed. Therefore, \r
+               you must explicitly close the connection by calling <see cref="MySqlConnection.Close"/> \r
+               or <see cref="MySqlConnection.Dispose"/>.\r
+       </para>\r
+\r
+</remarks>\r
+\r
+<example>\r
+       The following example creates a <see cref="MySqlCommand"/> and \r
+       a <B>MySqlConnection</B>. The <B>MySqlConnection</B> is opened and set as the  \r
+       <see cref="MySqlCommand.Connection"/> for the <B>MySqlCommand</B>. The example then calls  \r
+       <see cref="MySqlCommand.ExecuteNonQuery"/>, and closes the connection. To accomplish this, the <B>ExecuteNonQuery</B> is \r
+       passed a connection string and a query string that is a SQL INSERT \r
+       statement.\r
+       <code lang="Visual Basic">\r
+       <c>\r
+Public Sub InsertRow(myConnectionString As String)\r
+       ' If the connection string is null, use a default.\r
+       If myConnectionString = "" Then\r
+               myConnectionString = "Database=Test;Data Source=localhost;User Id=username;Password=pass"\r
+       End If\r
+       Dim myConnection As New MySqlConnection(myConnectionString)\r
+       Dim myInsertQuery As String = "INSERT INTO Orders (id, customerId, amount) Values(1001, 23, 30.66)"\r
+       Dim myCommand As New MySqlCommand(myInsertQuery)\r
+       myCommand.Connection = myConnection\r
+       myConnection.Open()\r
+       myCommand.ExecuteNonQuery()\r
+       myCommand.Connection.Close()\r
+End Sub\r
+</c> \r
+       </code>\r
+       <code lang="C#">\r
+<c>\r
+public void InsertRow(string myConnectionString) \r
+{\r
+       // If the connection string is null, use a default.\r
+       if(myConnectionString == "") \r
+       {\r
+               myConnectionString = "Database=Test;Data Source=localhost;User Id=username;Password=pass";\r
+       }\r
+       MySqlConnection myConnection = new MySqlConnection(myConnectionString);\r
+       string myInsertQuery = "INSERT INTO Orders (id, customerId, amount) Values(1001, 23, 30.66)";\r
+       MySqlCommand myCommand = new MySqlCommand(myInsertQuery);\r
+       myCommand.Connection = myConnection;\r
+       myConnection.Open();\r
+       myCommand.ExecuteNonQuery();\r
+       myCommand.Connection.Close();\r
+}\r
+</c>\r
+       </code>\r
+</example>\r
+\r
+\r
+</MyMembers>\r
+\r
+<MyMembers name="ConnectionTimeout">\r
+       <exception cref="System.ArgumentException">The value set is less than 0.</exception>\r
+       <remarks>\r
+               A value of 0 indicates no limit, and should be avoided in a \r
+               <see cref="MySqlConnection.ConnectionString"/> because an attempt to connect \r
+               will wait indefinitely.\r
+       </remarks>\r
+       <example>\r
+               The following example creates a MySqlConnection\r
+               and sets some of its properties in the connection string.\r
+               <code lang="Visual Basic">\r
+Public Sub CreateSqlConnection()\r
+       Dim myConnection As New MySqlConnection()\r
+       myConnection.ConnectionString = "Persist Security Info=False;Username=user;Password=pass;database=test1;server=localhost;Connect Timeout=30"\r
+       myConnection.Open()\r
+End Sub\r
+</code>\r
+<code lang="C#">\r
+public void CreateSqlConnection() \r
+{\r
+       MySqlConnection myConnection = new MySqlConnection();\r
+       myConnection.ConnectionString = "Persist Security Info=False;Username=user;Password=pass;database=test1;server=localhost;Connect Timeout=30";\r
+       myConnection.Open();\r
+}\r
+</code>                                \r
+       </example>\r
+</MyMembers>\r
+\r
+\r
+<MyMembers name="ConnectionString">\r
+       <remarks>\r
+       <para>The <B>ConnectionString</B> returned may not be exactly like what was originally\r
+       set but will be indentical in terms of keyword/value pairs.  Security information\r
+       will not be included unless the Persist Security Info value is set to true. \r
+       </para>\r
+       <para>You can use the <B>ConnectionString</B> property to connect to a database. \r
+       The following example illustrates a typical connection string.</para>\r
+       <c>"Persist Security Info=False;database=MyDB;server=MySqlServer;user id=myUser;Password=myPass"</c>\r
+       <para>The <B>ConnectionString</B> property can be set only when the connection is \r
+       closed. Many of the connection string values have corresponding read-only \r
+       properties. When the connection string is set, all of these properties are \r
+       updated, except when an error is detected. In this case, none of the properties \r
+       are updated. <see cref="MySqlConnection"/> properties return only those settings contained in the \r
+       <B>ConnectionString</B>.</para>\r
+       <para>To connect to a local machine, specify "localhost" for the server. If you do not \r
+       specify a server, localhost is assumed.</para>\r
+       <para>Resetting the <B>ConnectionString</B> on a closed connection resets all \r
+       connection string values (and related properties) including the password. For \r
+       example, if you set a connection string that includes "Database= MyDb", and \r
+       then reset the connection string to "Data Source=myserver;User Id=myUser;Password=myPass", \r
+       the <see cref="MySqlConnection.Database"/> property is no longer set to MyDb.</para>\r
+       <para>The connection string is parsed immediately after being set. If errors in \r
+       syntax are found when parsing, a runtime exception, such as <see cref="ArgumentException"/>, \r
+       is generated. Other errors can be found only when an attempt is made to open the \r
+       connection.</para>\r
+       <para>The basic format of a connection string consists of a series of keyword/value \r
+       pairs separated by semicolons. The equal sign (=) connects each keyword and its \r
+       value. To include values that contain a semicolon, single-quote character, or \r
+       double-quote character, the value must be enclosed in double quotes. If the \r
+       value contains both a semicolon and a double-quote character, the value can be \r
+       enclosed in single quotes. The single quote is also useful if the value begins \r
+       with a double-quote character. Conversely, the double quote can be used if the \r
+       value begins with a single quote. If the value contains both single-quote and \r
+       double-quote characters, the quote character used to enclose the value must be \r
+       doubled each time it occurs within the value.</para>\r
+       <para>To include preceding or trailing spaces in the string value, the value must \r
+       be enclosed in either single quotes or double quotes. Any leading or trailing \r
+       spaces around integer, Boolean, or enumerated values are ignored, even if \r
+       enclosed in quotes. However, spaces within a string literal keyword or value are \r
+       preserved. Using .NET Framework version 1.1, single or double quotes may be used \r
+       within a connection string without using delimiters (for example, Data Source= \r
+       my'Server or Data Source= my"Server), unless a quote character is the first or \r
+       last character in the value.</para>\r
+       <para>To include an equal sign (=) in a keyword or value, it must be preceded by \r
+       another equal sign. For example, in the hypothetical connection string</para>\r
+       <c>"key==word=value"</c>\r
+       <para></para>\r
+       <para>the keyword is "key=word" and the value is "value".</para>\r
+       <para>If a specific keyword in a keyword= value pair occurs multiple times in a \r
+       connection string, the last occurrence listed is used in the value set.</para>\r
+       <para>Keywords are not case sensitive.</para>\r
+       <para>The following table lists the valid names for keyword values within the \r
+       <B>ConnectionString</B>.</para>\r
+       <div class="tablediv"><table class="dtTABLE" cellspacing="0"><tr valign="top">\r
+               <th width="33%">Name</th>\r
+               <th width="33%">Default</th>\r
+               <th width="33%">Description</th>\r
+               </tr>\r
+               <tr>\r
+                       <td>Connect Timeout<para>  -or-  </para>Connection Timeout</td>\r
+                       <td>15</td>\r
+                       <td>The length of time (in seconds) to wait for a connection to the server before \r
+terminating the attempt and generating an error.</td>\r
+               </tr>\r
+               <tr>\r
+                       <td>\r
+                               Host<para>  -or-  </para>Server<para>  -or-  </para>Data Source<para>  -or-  </para>\r
+                               DataSource<para>  -or-  </para>Address<para>  -or-  </para>Addr<para>  -or-  </para>\r
+                               Network Address\r
+                       </td>\r
+                       <td>localhost</td>\r
+                       <td><para>The name or network address of the instance of MySQL to which to connect.  Multiple hosts can be\r
+                       specified separated by &amp;.  This can be useful where multiple MySQL servers are configured for replication\r
+                       and you are not concerned about the precise server you are connecting to.  No attempt is made by the provider to\r
+                       synchronize writes to the database so care should be taken when using this option.\r
+                       </para>\r
+                       <para>\r
+                               In Unix environment with Mono, this can be a fully qualified path to MySQL socket filename. With this configuration, the Unix socket will be used instead of TCP/IP socket.\r
+                               Currently only a single socket name can be given so accessing MySQL in a replicated environment using Unix sockets is not currently supported.\r
+                       </para>\r
+                       </td>\r
+               </tr>\r
+               <tr>\r
+                       <td>Port</td>\r
+                       <td>3306</td>\r
+                       <td>The port MySQL is using to listen for connections.  Specify -1 for this value to use a \r
+                               named pipe connection (Windows only). This value is ignored if Unix socket is used.</td>\r
+               </tr>\r
+               <tr>\r
+                       <td>Encrypt</td>\r
+                       <td>false</td>\r
+                       <td>When <B>true</B>, SSL encryption is used for all data sent between the \r
+client and server if the server has a certificate installed. Recognized values \r
+are <B>true</B>, <B>false</B>, <B>yes</B>, and <B>no</B>.<para><b>Note</b>  This parameter currently has no\r
+effect.</para></td>\r
+               </tr>\r
+               <tr>\r
+                       <td>Initial Catalog<para>  -or-  </para>Database</td>\r
+                       <td></td>\r
+                       <td>The name of the database to use intially</td>\r
+               </tr>\r
+               <tr>\r
+                       <td>Password<para>  -or-  </para>pwd</td>\r
+                       <td></td>\r
+                       <td>The password for the MySQL account being used.</td>\r
+               </tr>\r
+               <tr>\r
+                       <td>Persist Security Info</td>\r
+                       <td>false</td>\r
+                       <td>When set to <B>false</B> or <B>no</B> (strongly recommended), security-sensitive \r
+information, such as the password, is not returned as part of the connection if \r
+the connection is open or has ever been in an open state. Resetting the \r
+connection string resets all connection string values including the password. \r
+Recognized values are <B>true</B>, <B>false</B>, <B>yes</B>, and <B>no</B>.</td>\r
+               </tr>\r
+               <tr>\r
+                       <td>User Id<para>  -or-  </para>Username<para>  -or-  </para>Uid<para>  -or-  </para>User name</td>\r
+                       <td></td>\r
+                       <td>The MySQL login account being used.</td>\r
+               </tr>\r
+               </table>\r
+               </div>\r
+       <para>\r
+       The following table lists the valid names for connection pooling values within \r
+the <B>ConnectionString</B>. For more information about connection pooling, see \r
+Connection Pooling for the ByteFX Data Provider for MySQL.</para>\r
+       <div class="tablediv"><table class="dtTABLE" cellspacing="0"><tr valign="top">\r
+               <th width="33%">Name</th>\r
+               <th width="33%">Default</th>\r
+               <th width="33%">Description</th>\r
+               </tr>\r
+               <tr>\r
+                       <td>Connection Lifetime</td>\r
+                       <td>0</td>\r
+                       <td>When a connection is returned to the pool, its creation time is compared with \r
+the current time, and the connection is destroyed if that time span (in seconds) \r
+exceeds the value specified by <B>Connection Lifetime</B>. This is useful in \r
+clustered configurations to force load balancing between a running server and a \r
+server just brought online. \r
+<para>A value of zero (0) causes pooled connections to have the maximum connection \r
+timeout.</para></td>\r
+               </tr>\r
+               <tr>\r
+                       <td>Max Pool Size</td>\r
+                       <td>100</td>\r
+                       <td>The maximum number of connections allowed in the pool.</td>\r
+               </tr>\r
+               <tr>\r
+                       <td>Min Pool Size</td>\r
+                       <td>0</td>\r
+                       <td>The minimum number of connections allowed in the pool.</td>\r
+               </tr>\r
+               <tr>\r
+                       <td>Pooling</td>\r
+                       <td>true</td>\r
+                       <td>When <B>true</B>, the <B>MySqlConnection</B> object is drawn from the appropriate \r
+pool, or if necessary, is created and added to the appropriate pool. Recognized \r
+values are <B>true</B>, <B>false</B>, <B>yes</B>, and <B>no</B>.</td>\r
+               </tr>\r
+               <tr>\r
+                       <td>Use Pipe<para>  -or-  </para>Pipe</td>\r
+                       <td></td>\r
+                       <td>When set to the name of a named pipe, the <B>MySqlConnection</B> will attempt to connect to MySQL\r
+                       on that named pipe.<br/><br/>This settings only applies to the Windows platform.</td>\r
+               </tr>\r
+       </table></div>\r
+<para>When setting keyword or connection pooling values that require a Boolean \r
+value, you can use 'yes' instead of 'true', and 'no' instead of 'false'.</para>\r
+<para><B>Note</B>  The ByteFX Data Provider for MySQL uses the native socket protocol to \r
+communicate with MySQL.  Therefore, it does not support the use of an ODBC data source name (DSN) when \r
+connecting to MySQL because it does not add an ODBC layer.</para>\r
+<para><B>CAUTION</B>  In this release, the application should use caution when constructing a \r
+connection string based on user input (for example when retrieving user ID and password information from a \r
+dialog box, and appending it to the connection string). The application should \r
+ensure that a user cannot embed extra connection string parameters in these \r
+values (for example, entering a password as "validpassword;database=somedb" in \r
+an attempt to attach to a different database).</para>\r
+       </remarks>\r
+       <example>\r
+       The following example creates a <see cref="MySqlConnection"/> and sets some of its properties\r
+       <code lang="Visual Basic">\r
+       Public Sub CreateConnection()\r
+               Dim myConnection As New MySqlConnection()\r
+               myConnection.ConnectionString = "Persist Security Info=False;database=myDB;server=myHost;Connect Timeout=30;user id=myUser; pwd=myPass"\r
+               myConnection.Open()\r
+       End Sub 'CreateConnection\r
+       </code>\r
+       <code lang="C#">\r
+       public void CreateConnection() \r
+       {\r
+               MySqlConnection myConnection = new MySqlConnection();\r
+               myConnection.ConnectionString = "Persist Security Info=False;database=myDB;server=myHost;Connect Timeout=30;user id=myUser; pwd=myPass";\r
+               myConnection.Open();\r
+       }\r
+       </code>\r
+</example>\r
+       <example>\r
+               The following example creates a <see cref="MySqlConnection"/> in Unix environment with Mono installed. MySQL socket filename used in this example is "/var/lib/mysql/mysql.sock". The actual filename depends on your MySQL configuration.\r
+       <code lang="Visual Basic">\r
+       Public Sub CreateConnection()\r
+               Dim myConnection As New MySqlConnection()\r
+               myConnection.ConnectionString = "database=myDB;server=/var/lib/mysql/mysql.sock;user id=myUser; pwd=myPass"\r
+               myConnection.Open()\r
+       End Sub 'CreateConnection\r
+       </code>\r
+       <code lang="C#">\r
+       public void CreateConnection() \r
+       {\r
+               MySqlConnection myConnection = new MySqlConnection();\r
+               myConnection.ConnectionString = "database=myDB;server=/var/lib/mysql/mysql.sock;user id=myUser; pwd=myPass";\r
+               myConnection.Open();\r
+       }\r
+       </code>\r
+       </example>\r
+</MyMembers>\r
+</MyDocs>\r
diff --git a/mcs/class/ByteFX.Data/mysqlclient/docs/MySqlDataAdapter.xml b/mcs/class/ByteFX.Data/mysqlclient/docs/MySqlDataAdapter.xml
new file mode 100644 (file)
index 0000000..40d0785
--- /dev/null
@@ -0,0 +1,90 @@
+<MyDocs>\r
+<MyMembers name="Class">\r
+<remarks>\r
+       <para>\r
+       The <B>MySQLDataAdapter</B>, serves as a bridge between a <see cref="System.Data.DataSet"/>\r
+       and MySQL for retrieving and saving data. The <B>MySQLDataAdapter</B> provides this \r
+       bridge by mapping <see cref="DbDataAdapter.Fill"/>, which changes the data in the \r
+       <B>DataSet</B> to match the data in the data source, and <see cref="DbDataAdapter.Update"/>, \r
+       which changes the data in the data source to match the data in the <B>DataSet</B>, \r
+       using the appropriate SQL statements against the data source.\r
+       </para>\r
+       <para>\r
+       When the <B>MySQLDataAdapter</B> fills a <B>DataSet</B>, it will create the necessary \r
+       tables and columns for the returned data if they do not already exist. However, primary \r
+       key information will not be included in the implicitly created schema unless the \r
+       <see cref="System.Data.MissingSchemaAction"/> property is set to <see cref="System.Data.MissingSchemaAction.AddWithKey"/>. \r
+       You may also have the <B>MySQLDataAdapter</B> create the schema of the <B>DataSet</B>, \r
+       including primary key information, before filling it with data using <see cref="System.Data.Common.DbDataAdapter.FillSchema"/>. \r
+       </para>\r
+       <para><B>MySQLDataAdapter</B> is used in conjunction with <see cref="MySqlConnection"/>\r
+       and <see cref="MySqlCommand"/> to increase performance when connecting to a MySQL database.\r
+       </para>\r
+       <para>The <B>MySQLDataAdapter</B> also includes the <see cref="MySqlDataAdapter.SelectCommand"/>, \r
+       <see cref="MySqlDataAdapter.InsertCommand"/>, <see cref="MySqlDataAdapter.DeleteCommand"/>, \r
+       <see cref="MySqlDataAdapter.UpdateCommand"/>, and <see cref="DataAdapter.TableMappings"/> \r
+       properties to facilitate the loading and updating of data.\r
+       </para>\r
+       <para>When an instance of <B>MySQLDataAdapter</B> is created, the read/write properties \r
+       are set to initial values. For a list of these values, see the <B>MySQLDataAdapter</B> \r
+       constructor.\r
+       </para>\r
+</remarks>\r
+\r
+<example>\r
+       The following example creates a <see cref="MySqlCommand"/> and a <see cref="MySqlConnection"/>. \r
+       The <B>MySqlConnection</B> is opened and set as the <see cref="MySqlCommand.Connection"/> for the \r
+       <B>MySqlCommand</B>. The example then calls <see cref="MySqlCommand.ExecuteNonQuery"/>, and closes \r
+       the connection. To accomplish this, the <B>ExecuteNonQuery</B> is \r
+       passed a connection string and a query string that is a SQL INSERT \r
+       statement.\r
+       <code lang="Visual Basic">\r
+Public Function SelectRows(dataSet As DataSet, connection As String, query As String) As DataSet\r
+    Dim conn As New MySqlConnection(connection)\r
+    Dim adapter As New MySqlDataAdapter()\r
+    adapter.SelectCommand = new MySqlCommand(query, conn)\r
+    adapter.Fill(dataset)\r
+    Return dataset\r
+End Function\r
+       </code>\r
+       <code lang="C#">\r
+public DataSet SelectRows(DataSet dataset,string connection,string query) \r
+{\r
+    MySqlConnection conn = new MySqlConnection(connection);\r
+    MySqlDataAdapter adapter = new MySqlDataAdapter();\r
+    adapter.SelectCommand = new MySqlCommand(query, conn);\r
+    adapter.Fill(dataset);\r
+    return dataset;\r
+}\r
+       </code>\r
+</example>\r
+</MyMembers>\r
+\r
+<MyMembers name="ConnectionTimeout">\r
+       <exception cref="System.ArgumentException">The value set is less than 0.</exception>\r
+       <remarks>\r
+               A value of 0 indicates no limit, and should be avoided in a <see cref="MySqlConnection.ConnectionString"/> \r
+               because an attempt to connect will wait indefinitely.\r
+       </remarks>\r
+       <example>\r
+               The following example creates a MySqlConnection\r
+               and sets some of its properties in the connection string.\r
+               <code lang="Visual Basic"><c>\r
+Public Sub CreateSqlConnection()\r
+       Dim myConnection As New MySqlConnection()\r
+       myConnection.ConnectionString = "Persist Security Info=False;Username=user;Password=pass;database=test1;server=localhost;Connect Timeout=30"\r
+       myConnection.Open()\r
+End Sub\r
+</c></code>\r
+<code lang="C#"><c>\r
+public void CreateSqlConnection() \r
+{\r
+       MySqlConnection myConnection = new MySqlConnection();\r
+       myConnection.ConnectionString = "Persist Security Info=False;Username=user;Password=pass;database=test1;server=localhost;Connect Timeout=30";\r
+       myConnection.Open();\r
+}\r
+</c></code>                            \r
+       </example>\r
+</MyMembers>\r
+\r
+</MyDocs>
\ No newline at end of file
diff --git a/mcs/class/ByteFX.Data/mysqlclient/docs/MySqlDataReader.xml b/mcs/class/ByteFX.Data/mysqlclient/docs/MySqlDataReader.xml
new file mode 100644 (file)
index 0000000..b2f1f66
--- /dev/null
@@ -0,0 +1,78 @@
+<MyDocs>\r
+<MyMembers name="Class">\r
+<remarks>\r
+       <para>To create a <B>MySQLDataReader</B>, you must call the <see cref="MySqlCommand.ExecuteReader"/>\r
+       method of the <see cref="MySqlCommand"/> object, rather than directly using a constructor.\r
+       </para>\r
+       <para>While the <B>MySqlDataReader</B> is in use, the associated <see cref="MySqlConnection"/>\r
+        is busy serving the <B>MySqlDataReader</B>, and no other operations can be performed \r
+        on the <B>MySqlConnection</B> other than closing it. This is the case until the \r
+        <see cref="MySqlDataReader.Close"/> method of the <B>MySqlDataReader</B> is called. \r
+        </para>\r
+       <para>Changes made to a resultset by another process or thread while data is being \r
+       read may be visible to the user of the <B>MySqlDataReader</B>. However, the \r
+       precise behavior is timing dependent.\r
+       </para>\r
+       <para><see cref="MySqlDataReader.IsClosed"/> and <see cref="MySqlDataReader.RecordsAffected"/> \r
+       are the only properties that you can call after the <B>MySqlDataReader</B> is \r
+       closed. Though the <B>RecordsAffected</B> property may be accessed at any time \r
+       while the <B>MySqlDataReader</B> exists, always call <B>Close</B> before returning \r
+       the value of <B>RecordsAffected</B> to ensure an accurate return value.\r
+       </para>\r
+       <para>For optimal performance, <B>MySqlDataReader</B> avoids creating \r
+       unnecessary objects or making unnecessary copies of data. As a result, multiple calls \r
+       to methods such as <see cref="MySqlDataReader.GetValue"/> return a reference to the \r
+       same object. Use caution if you are modifying the underlying value of the objects \r
+       returned by methods such as <B>GetValue</B>.\r
+       </para>\r
+</remarks>\r
+\r
+<example>\r
+       The following example creates a <see cref="MySqlConnection"/>, \r
+       a <see cref="MySqlCommand"/>, and a <B>MySqlDataReader</B>. The example reads through \r
+       the data, writing it out to the console. Finally, the example closes the <B>MySqlDataReader</B>, then the \r
+       <B>MySqlConnection</B>.\r
+       <code lang="Visual Basic">\r
+Public Sub ReadMyData(myConnString As String)\r
+    Dim mySelectQuery As String = "SELECT OrderID, CustomerID FROM Orders"\r
+    Dim myConnection As New MySqlConnection(myConnString)\r
+    Dim myCommand As New MySqlCommand(mySelectQuery, myConnection)\r
+    myConnection.Open()\r
+    Dim myReader As MySqlDataReader\r
+    myReader = myCommand.ExecuteReader()\r
+    ' Always call Read before accessing data.\r
+    While myReader.Read()\r
+        Console.WriteLine((myReader.GetInt32(0) &amp; ", " &amp; myReader.GetString(1)))\r
+    End While\r
+    ' always call Close when done reading.\r
+    myReader.Close()\r
+    ' Close the connection when done with it.\r
+    myConnection.Close()\r
+End Sub 'ReadMyData\r
+       </code>\r
+       <code lang="C#">\r
+public void ReadMyData(string myConnString) {\r
+    string mySelectQuery = "SELECT OrderID, CustomerID FROM Orders";\r
+    MySqlConnection myConnection = new MySqlConnection(myConnString);\r
+    MySqlCommand myCommand = new MySqlCommand(mySelectQuery,myConnection);\r
+    myConnection.Open();\r
+    MySqlDataReader myReader;\r
+    myReader = myCommand.ExecuteReader();\r
+    // Always call Read before accessing data.\r
+    while (myReader.Read()) {\r
+       Console.WriteLine(myReader.GetInt32(0) + ", " + myReader.GetString(1));\r
+    }\r
+    // always call Close when done reading.\r
+    myReader.Close();\r
+    // Close the connection when done with it.\r
+    myConnection.Close();\r
+ }\r
+       </code>\r
+</example>\r
+\r
+\r
+</MyMembers>\r
+\r
+\r
+\r
+</MyDocs>
\ No newline at end of file
diff --git a/mcs/class/ByteFX.Data/mysqlclient/docs/MySqlException.xml b/mcs/class/ByteFX.Data/mysqlclient/docs/MySqlException.xml
new file mode 100644 (file)
index 0000000..d7df7b3
--- /dev/null
@@ -0,0 +1,54 @@
+<MyDocs>\r
+<MyMembers name="Class">\r
+<remarks>\r
+       <para>\r
+       This class is created whenever the ByteFX Data Provider for MySQL \r
+       encounters an error generated from the server.\r
+       </para>\r
+       <para>\r
+       Any open connections are not automatically closed when an exception is thrown.  If \r
+       the client application determines that the exception is fatal, it should close any open\r
+       <see cref="MySqlDataReader"/> objects or <see cref="MySqlConnection"/> objects.\r
+       </para>\r
+</remarks>\r
+\r
+<example>\r
+       The following example generates a <B>MySqlException</B> due to a missing server, \r
+       and then displays the exception.\r
+       \r
+       <code lang="Visual Basic">\r
+Public Sub ShowException()\r
+     Dim mySelectQuery As String = "SELECT column1 FROM table1"\r
+     Dim myConnection As New MySqlConnection ("Data Source=localhost;Database=Sample;")\r
+     Dim myCommand As New MySqlCommand(mySelectQuery, myConnection)\r
+\r
+     Try\r
+         myCommand.Connection.Open()\r
+     Catch e As MySqlException\r
+               MessageBox.Show( e.Message )\r
+     End Try\r
+ End Sub\r
+       </code>\r
+       <code lang="C#">\r
+public void ShowException() \r
+{\r
+   string mySelectQuery = "SELECT column1 FROM table1";\r
+   MySqlConnection myConnection =\r
+      new MySqlConnection("Data Source=localhost;Database=Sample;");\r
+   MySqlCommand myCommand = new MySqlCommand(mySelectQuery,myConnection);\r
+\r
+   try \r
+   {\r
+      myCommand.Connection.Open();\r
+   }\r
+   catch (MySqlException e) \r
+   {\r
+               MessageBox.Show( e.Message );\r
+   }\r
+}\r
+       </code>\r
+</example>\r
+\r
+\r
+</MyMembers>\r
+</MyDocs>
\ No newline at end of file
diff --git a/mcs/class/ByteFX.Data/mysqlclient/docs/MySqlHelper.xml b/mcs/class/ByteFX.Data/mysqlclient/docs/MySqlHelper.xml
new file mode 100644 (file)
index 0000000..d7df7b3
--- /dev/null
@@ -0,0 +1,54 @@
+<MyDocs>\r
+<MyMembers name="Class">\r
+<remarks>\r
+       <para>\r
+       This class is created whenever the ByteFX Data Provider for MySQL \r
+       encounters an error generated from the server.\r
+       </para>\r
+       <para>\r
+       Any open connections are not automatically closed when an exception is thrown.  If \r
+       the client application determines that the exception is fatal, it should close any open\r
+       <see cref="MySqlDataReader"/> objects or <see cref="MySqlConnection"/> objects.\r
+       </para>\r
+</remarks>\r
+\r
+<example>\r
+       The following example generates a <B>MySqlException</B> due to a missing server, \r
+       and then displays the exception.\r
+       \r
+       <code lang="Visual Basic">\r
+Public Sub ShowException()\r
+     Dim mySelectQuery As String = "SELECT column1 FROM table1"\r
+     Dim myConnection As New MySqlConnection ("Data Source=localhost;Database=Sample;")\r
+     Dim myCommand As New MySqlCommand(mySelectQuery, myConnection)\r
+\r
+     Try\r
+         myCommand.Connection.Open()\r
+     Catch e As MySqlException\r
+               MessageBox.Show( e.Message )\r
+     End Try\r
+ End Sub\r
+       </code>\r
+       <code lang="C#">\r
+public void ShowException() \r
+{\r
+   string mySelectQuery = "SELECT column1 FROM table1";\r
+   MySqlConnection myConnection =\r
+      new MySqlConnection("Data Source=localhost;Database=Sample;");\r
+   MySqlCommand myCommand = new MySqlCommand(mySelectQuery,myConnection);\r
+\r
+   try \r
+   {\r
+      myCommand.Connection.Open();\r
+   }\r
+   catch (MySqlException e) \r
+   {\r
+               MessageBox.Show( e.Message );\r
+   }\r
+}\r
+       </code>\r
+</example>\r
+\r
+\r
+</MyMembers>\r
+</MyDocs>
\ No newline at end of file
diff --git a/mcs/class/ByteFX.Data/mysqlclient/docs/MySqlParameter.xml b/mcs/class/ByteFX.Data/mysqlclient/docs/MySqlParameter.xml
new file mode 100644 (file)
index 0000000..9bdf2ed
--- /dev/null
@@ -0,0 +1,45 @@
+<MyDocs>\r
+<MyMembers name="Class">\r
+<remarks>\r
+       Parameter names are not case sensitive.\r
+</remarks>\r
+\r
+<example>\r
+       The following example creates multiple instances of <B>MySqlParameter</B> through the \r
+       <see cref="MySqlParameterCollection"/> collection within the <see cref="MySqlDataAdapter"/>.  \r
+       These parameters are used to select data from the data source and place the data \r
+       in the <see cref="DataSet"/>. This example assumes that a <B>DataSet</B> and a \r
+       <B>MySqlDataAdapter</B> have already been created with the appropriate schema, commands, \r
+       and connection.\r
+<code lang="Visual Basic">\r
+Public Sub AddSqlParameters()\r
+    ' ...\r
+    ' create myDataSet and myDataAdapter\r
+    ' ...\r
+    myDataAdapter.SelectCommand.Parameters.Add("@CategoryName", MySqlDbType.VarChar, 80).Value = "toasters"\r
+    myDataAdapter.SelectCommand.Parameters.Add("@SerialNum", MySqlDbType.Long).Value = 239\r
+    \r
+    myDataAdapter.Fill(myDataSet)\r
+End Sub 'AddSqlParameters \r
+       </code>\r
+       <code lang="C#">\r
+public void AddSqlParameters() \r
+{\r
+// ...\r
+// create myDataSet and myDataAdapter\r
+// ...\r
+\r
+  myDataAdapter.SelectCommand.Parameters.Add("@CategoryName", MySqlDbType.VarChar, 80).Value = "toasters";\r
+  myDataAdapter.SelectCommand.Parameters.Add("@SerialNum", MySqlDbType.Long).Value = 239;\r
+  myDataAdapter.Fill(myDataSet);\r
+\r
+}\r
+       </code>\r
+</example>\r
+\r
+\r
+</MyMembers>\r
+\r
+\r
+\r
+</MyDocs>
\ No newline at end of file
diff --git a/mcs/class/ByteFX.Data/mysqlclient/docs/MySqlParameterCollection.xml b/mcs/class/ByteFX.Data/mysqlclient/docs/MySqlParameterCollection.xml
new file mode 100644 (file)
index 0000000..8778927
--- /dev/null
@@ -0,0 +1,45 @@
+<MyDocs>\r
+<MyMembers name="Class">\r
+<remarks>\r
+       The number of the parameters in the collection must be equal to the number of \r
+parameter placeholders within the command text, or an exception will be generated.\r
+</remarks>\r
+\r
+<example>\r
+       The following example creates multiple instances of <see cref="MySqlParameter"/> \r
+       through the <B>MySqlParameterCollection</B> collection within the <see cref="MySqlDataAdapter"/>.  \r
+       These parameters are used to select data within the data source and place the data in \r
+       the <see cref="DataSet"/>. This code assumes that a <B>DataSet</B> and a <B>MySqlDataAdapter</B> \r
+       have already been created with the appropriate schema, commands, and connection.\r
+<code lang="Visual Basic">\r
+Public Sub AddParameters()\r
+    ' ...\r
+    ' create myDataSet and myDataAdapter\r
+    ' ...\r
+    myDataAdapter.SelectCommand.Parameters.Add("@CategoryName", MySqlDbType.VarChar, 80).Value = "toasters"\r
+    myDataAdapter.SelectCommand.Parameters.Add("@SerialNum", MySqlDbType.Long).Value = 239\r
+    \r
+    myDataAdapter.Fill(myDataSet)\r
+End Sub 'AddSqlParameters \r
+       </code>\r
+       <code lang="C#">\r
+public void AddSqlParameters() \r
+{\r
+// ...\r
+// create myDataSet and myDataAdapter\r
+// ...\r
+\r
+  myDataAdapter.SelectCommand.Parameters.Add("@CategoryName", MySqlDbType.VarChar, 80).Value = "toasters";\r
+  myDataAdapter.SelectCommand.Parameters.Add("@SerialNum", MySqlDbType.Long).Value = 239;\r
+  myDataAdapter.Fill(myDataSet);\r
+\r
+}\r
+       </code>\r
+</example>\r
+\r
+\r
+</MyMembers>\r
+\r
+\r
+\r
+</MyDocs>
\ No newline at end of file
diff --git a/mcs/class/ByteFX.Data/mysqlclient/docs/MySqlTransaction.xml b/mcs/class/ByteFX.Data/mysqlclient/docs/MySqlTransaction.xml
new file mode 100644 (file)
index 0000000..2211573
--- /dev/null
@@ -0,0 +1,111 @@
+<MyDocs>\r
+<MyMembers name="Class">\r
+<remarks>\r
+       The application creates a <B>MySqlTransaction</B> object by calling <see cref="MySqlConnection.BeginTransaction"/>\r
+       on the <see cref="MySqlConnection"/> object. All subsequent operations associated with the \r
+       transaction (for example, committing or aborting the transaction), are performed on the \r
+       <B>MySqlTransaction</B> object.\r
+</remarks>\r
+\r
+<example>\r
+       The following example creates a <see cref="MySqlConnection"/> and a <B>MySqlTransaction</B>. \r
+       It also demonstrates how to use the <see cref="MySqlConnection.BeginTransaction"/>, \r
+       <see cref="MySqlTransaction.Commit"/>, and <see cref="MySqlTransaction.Rollback"/> methods.\r
+       <code lang="Visual Basic">\r
+Public Sub RunTransaction(myConnString As String)\r
+    Dim myConnection As New MySqlConnection(myConnString)\r
+    myConnection.Open()\r
+    \r
+    Dim myCommand As MySqlCommand = myConnection.CreateCommand()\r
+    Dim myTrans As MySqlTransaction\r
+    \r
+    ' Start a local transaction\r
+    myTrans = myConnection.BeginTransaction()\r
+    ' Must assign both transaction object and connection\r
+    ' to Command object for a pending local transaction\r
+    myCommand.Connection = myConnection\r
+    myCommand.Transaction = myTrans\r
+    \r
+    Try\r
+      myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (100, 'Description')"\r
+      myCommand.ExecuteNonQuery()\r
+      myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (101, 'Description')"\r
+      myCommand.ExecuteNonQuery()\r
+      myTrans.Commit()\r
+      Console.WriteLine("Both records are written to database.")\r
+    Catch e As Exception\r
+      Try\r
+        myTrans.Rollback()\r
+      Catch ex As MySqlException\r
+        If Not myTrans.Connection Is Nothing Then\r
+          Console.WriteLine("An exception of type " &amp; ex.GetType().ToString() &amp; _\r
+                            " was encountered while attempting to roll back the transaction.")\r
+        End If\r
+      End Try\r
+    \r
+      Console.WriteLine("An exception of type " &amp; e.GetType().ToString() &amp; _\r
+                      "was encountered while inserting the data.")\r
+      Console.WriteLine("Neither record was written to database.")\r
+    Finally\r
+      myConnection.Close()\r
+    End Try\r
+End Sub 'RunTransaction\r
+       </code>\r
+       <code lang="C#">\r
+public void RunTransaction(string myConnString) \r
+ {\r
+    MySqlConnection myConnection = new MySqlConnection(myConnString);\r
+    myConnection.Open();\r
+\r
+    MySqlCommand myCommand = myConnection.CreateCommand();\r
+    MySqlTransaction myTrans;\r
+\r
+    // Start a local transaction\r
+    myTrans = myConnection.BeginTransaction();\r
+    // Must assign both transaction object and connection\r
+    // to Command object for a pending local transaction\r
+    myCommand.Connection = myConnection;\r
+    myCommand.Transaction = myTrans;\r
+\r
+    try\r
+    {\r
+      myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (100, 'Description')";\r
+      myCommand.ExecuteNonQuery();\r
+      myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (101, 'Description')";\r
+      myCommand.ExecuteNonQuery();\r
+      myTrans.Commit();\r
+      Console.WriteLine("Both records are written to database.");\r
+    }\r
+    catch(Exception e)\r
+    {\r
+      try\r
+      {\r
+        myTrans.Rollback();\r
+      }\r
+      catch (MySqlException ex)\r
+      {\r
+        if (myTrans.Connection != null)\r
+        {\r
+          Console.WriteLine("An exception of type " + ex.GetType() +\r
+                            " was encountered while attempting to roll back the transaction.");\r
+        }\r
+      }\r
+    \r
+      Console.WriteLine("An exception of type " + e.GetType() +\r
+                        " was encountered while inserting the data.");\r
+      Console.WriteLine("Neither record was written to database.");\r
+    }\r
+    finally \r
+    {\r
+      myConnection.Close();\r
+    }\r
+}\r
+       </code>\r
+</example>\r
+\r
+\r
+</MyMembers>\r
+\r
+\r
+\r
+</MyDocs>
\ No newline at end of file
index 8ce6aed3d24cf0e95028352f7775b5580905c317..e2f325cae015de1b126bb85313ca3f9d0c5ac38a 100755 (executable)
-// ByteFX.Data data access components for .Net
-// Copyright (C) 2002-2003  ByteFX, Inc.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// 
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-// 
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-using System;
-using System.Data;
-using System.Text;
-using System.ComponentModel;
-using System.ComponentModel.Design.Serialization;
-using System.Reflection;
-
-namespace ByteFX.Data.MySqlClient
-{
-       /// <summary>
-       /// Represents a parameter to a <see cref="MySqlCommand"/>, and optionally, its mapping to <see cref="DataSet"/> columns. This class cannot be inherited.
-       /// </summary>
-       [TypeConverter(typeof(MySqlParameter.MySqlParameterConverter))]
-       public sealed class MySqlParameter : MarshalByRefObject, IDataParameter, IDbDataParameter, ICloneable
-       {
-               private MySqlDbType                     dbType  = MySqlDbType.Null;
-               private DbType                          genericType;
-               private ParameterDirection      direction = ParameterDirection.Input;
-               private bool                            isNullable  = false;
-               private string                          paramName;
-               private string                          sourceColumn;
-               private DataRowVersion          sourceVersion = DataRowVersion.Current;
-               private object                          paramValue = DBNull.Value;
-               private int                                     size;
-               private byte                            precision=0, scale=0;
-
-               #region Constructors
-
-               /// <summary>
-               /// Initializes a new instance of the MySqlParameter class.
-               /// </summary>
-               public MySqlParameter()
-               {
-               }
-
-               /// <summary>
-               /// Initializes a new instance of the <see cref="MySqlParameter"/> class with the parameter name and a value of the new MySqlParameter.
-               /// </summary>
-               /// <param name="parameterName">The name of the parameter to map. </param>
-               /// <param name="value">An <see cref="Object"/> that is the value of the <see cref="MySqlParameter"/>. </param>
-               public MySqlParameter(string parameterName, object value)
-               {
-                       ParameterName = parameterName;
-                       paramValue = value;
-                       dbType = GetMySqlType( paramValue.GetType() );
-                       genericType = GetGenericType( paramValue.GetType() );
-               }
-
-               /// <summary>
-               /// Initializes a new instance of the <see cref="MySqlParameter"/> class with the parameter name and the data type.
-               /// </summary>
-               /// <param name="parameterName">The name of the parameter to map. </param>
-               /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
-               public MySqlParameter( string parameterName, MySqlDbType dbType)
-               {
-                       ParameterName = parameterName;
-                       this.dbType   = dbType;
-               }
-
-               /// <summary>
-               /// Initializes a new instance of the <see cref="MySqlParameter"/> class with the parameter name, the <see cref="MySqlDbType"/>, and the size.
-               /// </summary>
-               /// <param name="parameterName">The name of the parameter to map. </param>
-               /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
-               /// <param name="size">The length of the parameter. </param>
-               public MySqlParameter( string parameterName, MySqlDbType dbType, int size )
-               {
-                       ParameterName = parameterName;
-                       this.dbType = dbType;
-                       this.size = size;
-               }
-
-               /// <summary>
-               /// Initializes a new instance of the <see cref="MySqlParameter"/> class with the parameter name, the <see cref="MySqlDbType"/>, the size, and the source column name.
-               /// </summary>
-               /// <param name="parameterName">The name of the parameter to map. </param>
-               /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
-               /// <param name="size">The length of the parameter. </param>
-               /// <param name="sourceColumn">The name of the source column. </param>
-               public MySqlParameter( string parameterName, MySqlDbType dbType, int size, string sourceColumn )
-               {
-                       ParameterName = parameterName;
-                       this.dbType = dbType;
-                       this.size = size;
-                       this.direction = ParameterDirection.Input;
-                       this.precision = 0;
-                       this.scale = 0;
-                       this.sourceColumn = sourceColumn;
-                       this.sourceVersion = DataRowVersion.Current;
-                       this.paramValue =null;
-               }
-
-               internal MySqlParameter(string name, MySqlDbType type, ParameterDirection dir, string col, DataRowVersion ver, object val)
-               {
-                       if (direction != ParameterDirection.Input)
-                               throw new ArgumentException("Only input parameters are supported by MySql");
-                       dbType = type;
-                       direction = dir;
-                       ParameterName = name;
-                       sourceColumn = col;
-                       sourceVersion = ver;
-                       paramValue = val;
-               }
-
-               /// <summary>
-               /// Initializes a new instance of the <see cref="MySqlParameter"/> class with the parameter name, the type of the parameter, the size of the parameter, a <see cref="ParameterDirection"/>, the precision of the parameter, the scale of the parameter, the source column, a <see cref="DataRowVersion"/> to use, and the value of the parameter.
-               /// </summary>
-               /// <param name="parameterName">The name of the parameter to map. </param>
-               /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
-               /// <param name="size">The length of the parameter. </param>
-               /// <param name="direction">One of the <see cref="ParameterDirection"/> values. </param>
-               /// <param name="isNullable">true if the value of the field can be null, otherwise false. </param>
-               /// <param name="precision">The total number of digits to the left and right of the decimal point to which <see cref="MySqlParameter.Value"/> is resolved.</param>
-               /// <param name="scale">The total number of decimal places to which <see cref="MySqlParameter.Value"/> is resolved. </param>
-               /// <param name="sourceColumn">The name of the source column. </param>
-               /// <param name="sourceVersion">One of the <see cref="DataRowVersion"/> values. </param>
-               /// <param name="value">An <see cref="Object"/> that is the value of the <see cref="MySqlParameter"/>. </param>
-               /// <exception cref="ArgumentException"/>
-               public MySqlParameter( string parameterName, MySqlDbType dbType, int size, ParameterDirection direction,
-                       bool isNullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion,
-                       object value)
-               {
-                       if (direction != ParameterDirection.Input)
-                               throw new ArgumentException("Only input parameters are supported by MySql");
-
-                       ParameterName = parameterName;
-                       this.dbType = dbType;
-                       this.size = size;
-                       this.direction = direction;
-                       this.precision = precision;
-                       this.scale = scale;
-                       this.sourceColumn = sourceColumn;
-                       this.sourceVersion = sourceVersion;
-                       this.paramValue = value;
-               }
-               #endregion
-
-               #region Properties
-
-               /// <summary>
-               /// Gets or sets the <see cref="DbType"/> of the parameter.
-               /// </summary>
-               public DbType DbType 
-               {
-                       get 
-                       { 
-                               return genericType; 
-                       }
-                       set 
-                       { 
-                               genericType = value; 
-                               switch (genericType) 
-                               {
-                                       case DbType.AnsiString:
-                                       case DbType.AnsiStringFixedLength:
-                                       case DbType.String:
-                                       case DbType.StringFixedLength:
-                                       case DbType.Guid:
-                                               MySqlDbType = MySqlDbType.VarChar; break;
-
-                                       case DbType.Byte:
-                                       case DbType.SByte:
-                                       case DbType.Boolean:
-                                               MySqlDbType = MySqlDbType.Byte; break;
-
-                                       case DbType.Int16:
-                                       case DbType.UInt16:
-                                               MySqlDbType = MySqlDbType.Short; break;
-
-                                       case DbType.Int32:
-                                       case DbType.UInt32:
-                                               MySqlDbType = MySqlDbType.Int; break;
-                                               
-                                       case DbType.Int64:
-                                       case DbType.UInt64:
-                                               MySqlDbType = MySqlDbType.BigInt; break;
-
-                                       case DbType.DateTime:
-                                               MySqlDbType = MySqlDbType.Datetime;     break;
-
-                                       case DbType.Date:
-                                               MySqlDbType = MySqlDbType.Date; break;
-
-                                       case DbType.Time:
-                                               MySqlDbType = MySqlDbType.Time; break;
-
-                                       case DbType.Single:
-                                               MySqlDbType = MySqlDbType.Float; break;
-                                       case DbType.Double:
-                                       case DbType.Currency:
-                                               MySqlDbType = MySqlDbType.Double; break;
-
-                                       case DbType.Decimal:
-                                       case DbType.VarNumeric:
-                                               MySqlDbType = MySqlDbType.Decimal; break;
-
-                                       case DbType.Binary:
-                                       case DbType.Object:
-                                               MySqlDbType = MySqlDbType.Blob; break;
-                               }
-                       }
-               }
-
-               /// <summary>
-               /// Gets or sets a value indicating whether the parameter is input-only, output-only, bidirectional, or a stored procedure return value parameter.
-               /// As of MySql version 4.1 and earlier, input-only is the only valid choice.
-               /// </summary>
-               [Category("Data")]
-               public ParameterDirection Direction 
-               {
-                       get { return direction; }
-                       set { direction = value; }
-               }
-
-               /// <summary>
-               /// Gets or sets a value indicating whether the parameter accepts null values.
-               /// </summary>
-               [Browsable(false)]
-               public Boolean IsNullable 
-               {
-                       get { return isNullable; }
-               }
-
-               /// <summary>
-               /// Gets or sets the MySqlDbType of the parameter.
-               /// </summary>
-               [Category("Data")]
-               public MySqlDbType MySqlDbType 
-               {
-                       get  
-                       { 
-                               return dbType; 
-                       }
-                       set  
-                       { 
-                               dbType = value;  
-                       }
-               }
-
-               /// <summary>
-               /// Gets or sets the name of the MySqlParameter.
-               /// </summary>
-               [Category("Misc")]
-               public String ParameterName 
-               {
-                       get { return paramName; }
-                       set 
-                       { 
-                               paramName = value; 
-                               if (paramName[0] == '@')
-                                       paramName = paramName.Substring(1, paramName.Length-1);
-                       }
-               }
-
-               /// <summary>
-               /// Gets or sets the maximum number of digits used to represent the <see cref="Value"/> property.
-               /// </summary>
-               [Category("Data")]
-               public byte Precision 
-               {
-                       get { return precision; }
-                       set { precision = value; }
-               }
-
-               /// <summary>
-               /// Gets or sets the number of decimal places to which <see cref="Value"/> is resolved.
-               /// </summary>
-               [Category("Data")]
-               public byte Scale 
-               {
-                       get { return scale; }
-                       set { scale = value; }
-               }
-
-               /// <summary>
-               /// Gets or sets the maximum size, in bytes, of the data within the column.
-               /// </summary>
-               [Category("Data")]
-               public int Size 
-               {
-                       get { return size; }
-                       set { size = value; }
-               }
-
-               /// <summary>
-               /// Gets or sets the name of the source column that is mapped to the <see cref="DataSet"/> and used for loading or returning the <see cref="Value"/>.
-               /// </summary>
-               [Category("Data")]
-               public String SourceColumn 
-               {
-                       get { return sourceColumn; }
-                       set { sourceColumn = value; }
-               }
-
-               /// <summary>
-               /// Gets or sets the <see cref="DataRowVersion"/> to use when loading <see cref="Value"/>.
-               /// </summary>
-               [Category("Data")]
-               public DataRowVersion SourceVersion 
-               {
-                       get { return sourceVersion; }
-                       set { sourceVersion = value; }
-               }
-
-               /// <summary>
-               /// Gets or sets the value of the parameter.
-               /// </summary>
-               [TypeConverter(typeof(StringConverter))]
-               [Category("Data")]
-               public object Value 
-               {
-                       get     { return paramValue; }
-                       set     
-                       { 
-                               paramValue = value; 
-                               if (dbType == MySqlDbType.Null) 
-                               {
-                                       dbType = GetMySqlType( paramValue.GetType() );
-                                       genericType = GetGenericType( paramValue.GetType() );
-                               }
-                       }
-               }
-
-               #endregion
-
-               private void EscapeByteArray( byte[] bytes, System.IO.MemoryStream s )
-               {
-                       byte[] newbytes = new byte[ bytes.Length * 2 ];
-
-                       int newx=0;
-                       for (int x=0; x < bytes.Length; x++)
-                       {
-                               byte b = bytes[x];
-                               if (b == '\0') 
-                               {
-                                       newbytes[newx++] = (byte)'\\';
-                                       newbytes[newx++] = (byte)'0';
-                               }
-                               else 
-                               {
-                                       if (b == '\\' || b == '\'' || b == '"')
-                                               newbytes[newx++] = (byte)'\\';
-                                       newbytes[newx++] = b;
-                               }
-                       }
-                       s.Write( newbytes, 0, newx );
-               }
-
-               /// <summary>
-               /// Overridden. Gets a string containing the <see cref="ParameterName"/>.
-               /// </summary>
-               /// <returns></returns>
-               public override string ToString() 
-               {
-                       return paramName;
-               }
-
-               private string EscapeString( string s )
-               {
-                       StringBuilder sb = new StringBuilder();
-
-                       foreach (char c in s) 
-                       {
-                               if (c == '\'')
-                                       sb.Append(c);
-                               sb.Append(c);
-                       }
-                       return sb.ToString();
-               }
-
-               internal void SerializeToBytes( System.IO.MemoryStream s, MySqlConnection conn )
-               {
-                       string  parm_string = null;
-                       byte[]  bytes = null;
-
-                       //TODO:  should value == null throw an exception?
-                       if (Value == DBNull.Value || Value == null)
-                               parm_string = "Null";
-                       else if (paramValue is bool)
-                               parm_string = Convert.ToByte(paramValue).ToString();
-                       else 
-                       {
-                               switch (dbType) 
-                               {
-                                       case MySqlDbType.Null:
-                                               parm_string = "Null";
-                                               break;
-
-                                       case MySqlDbType.VarChar:
-                                       case MySqlDbType.String:
-                                               parm_string = "'" + EscapeString(Value.ToString()) + "'";
-                                               break;
-
-                                       case MySqlDbType.Double:
-                                               parm_string = Convert.ToDouble(Value).ToString( conn.NumberFormat );
-                                               break;
-
-                                       case MySqlDbType.Float:
-                                               parm_string = Convert.ToSingle(Value).ToString( conn.NumberFormat );
-                                               break;
-
-                                       case MySqlDbType.Decimal:
-                                               parm_string = Convert.ToDecimal(Value).ToString( conn.NumberFormat );
-                                               break;
-
-                                       case MySqlDbType.Time:
-                                               if (Value is DateTime)
-                                                       parm_string = String.Format("'{0:HH:mm:ss}'", ((DateTime)Value));
-                                               else 
-                                                       parm_string = String.Format("'{0}'", Value.ToString());
-                                               break;
-
-                                       case MySqlDbType.Date:
-                                               if (Value is DateTime)
-                                                       parm_string = String.Format("'{0:yyyy-MM-dd}'", ((DateTime)Value));
-                                               else 
-                                                       parm_string = "'" + Value.ToString() + "'";
-                                               break;
-
-                                       case MySqlDbType.Datetime:
-                                               if (Value is DateTime)
-                                                       parm_string = String.Format("'{0:yyyy-MM-dd HH:mm:ss}'", ((DateTime)Value));
-                                               else
-                                                       parm_string = "'" + Value + "'";
-                                               break;
-
-                                       case MySqlDbType.Blob:
-                                       case MySqlDbType.MediumBlob:
-                                       case MySqlDbType.LongBlob:
-                                       case MySqlDbType.TinyBlob:
-                                               Type t = paramValue.GetType();
-
-                                               if (t == typeof(System.Byte[]))
-                                               {
-                                                       s.WriteByte((byte)'\'');
-                                                       EscapeByteArray( (byte[])paramValue, s );
-                                                       s.WriteByte((byte)'\'');
-                                                       return;
-                                               }
-                                               else if(t == typeof(string)) 
-                                                       parm_string = "'" + EscapeString((string)paramValue) + "'";
-                                               else if (t == typeof(System.Guid))
-                                               {
-                                                       parm_string = "'" + paramValue.ToString() + "'";
-                                               }
-                                               break;
-
-                                       default:
-                                               parm_string = Value.ToString();
-                                               break;
-                               }
-                       }
-
-                       bytes = conn.Encoding.GetBytes(parm_string);
-                       s.Write(bytes, 0, bytes.Length);
-               }
-
-               private DbType GetGenericType( Type systemType )
-               {
-                       switch ( Type.GetTypeCode(systemType) )
-                       {
-                               case TypeCode.Boolean: return DbType.Boolean;
-                               case TypeCode.Byte: return DbType.Byte;
-                               case TypeCode.Char: return DbType.StringFixedLength;
-                               case TypeCode.DateTime: return DbType.DateTime;
-                               case TypeCode.Decimal: return DbType.Decimal;
-                               case TypeCode.Double: return DbType.Double;
-                               case TypeCode.Int16: return DbType.Int16;
-                               case TypeCode.Int32: return DbType.Int32;
-                               case TypeCode.Int64: return DbType.Int64;
-                               case TypeCode.Object: return DbType.Binary;
-                               case TypeCode.SByte: return DbType.SByte;
-                               case TypeCode.Single: return DbType.Single;
-                               case TypeCode.String: return DbType.String;
-                               case TypeCode.UInt16: return DbType.UInt16;
-                               case TypeCode.UInt32: return DbType.UInt32;
-                               case TypeCode.UInt64: return DbType.UInt64;
-                       }
-                       return DbType.Object;
-               }
-
-               private MySqlDbType GetMySqlType( Type systemType )
-               {
-                       switch (Type.GetTypeCode( systemType ))
-                       {
-                               case TypeCode.Empty:
-                                       throw new SystemException("Invalid data type");
-
-                               case TypeCode.Object: return MySqlDbType.Blob;
-                               case TypeCode.DBNull: return MySqlDbType.Null;
-                               case TypeCode.Char:
-                               case TypeCode.SByte:
-                               case TypeCode.Boolean:
-                               case TypeCode.Byte: return MySqlDbType.Byte;
-                               case TypeCode.Int16:
-                               case TypeCode.UInt16: return MySqlDbType.Int24;
-                               case TypeCode.Int32:
-                               case TypeCode.UInt32: return MySqlDbType.Int;
-                               case TypeCode.Int64:
-                               case TypeCode.UInt64: return MySqlDbType.BigInt;
-                               case TypeCode.Single: return MySqlDbType.Float;
-                               case TypeCode.Double: return MySqlDbType.Double;
-                               case TypeCode.Decimal: return MySqlDbType.Decimal;
-                               case TypeCode.DateTime: return MySqlDbType.Datetime;
-                               case TypeCode.String: return MySqlDbType.VarChar;
-
-                               default:
-                                       throw new SystemException("Value is of unknown data type");
-                       }
-               }
-
-
-               #region ICloneable
-               object System.ICloneable.Clone() 
-               {
-                       MySqlParameter clone = new MySqlParameter( paramName, dbType, direction,
-                               sourceColumn, sourceVersion, paramValue );
-                       return clone;
-               }
-               #endregion
-
-               /* A TypeConverter for the Triangle object.  Note that you can make it internal,
-                               private, or any scope you want and the designers will still be able to use
-                               it through the TypeDescriptor object.  This type converter provides the
-                               capability to convert to an InstanceDescriptor.  This object can be used by 
-                  the .NET Framework to generate source code that creates an instance of a 
-                  Triangle object. */
-               internal class MySqlParameterConverter : TypeConverter
-               {
-                       /* This method overrides CanConvertTo from TypeConverter. This is called when someone
-                                       wants to convert an instance of Triangle to another type.  Here,
-                                       only conversion to an InstanceDescriptor is supported. */
-                       public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
-                       {
-                               if (destinationType == typeof(InstanceDescriptor))
-                               {
-                                       return true;
-                               }
-
-                               // Always call the base to see if it can perform the conversion.
-                               return base.CanConvertTo(context, destinationType);
-                       }
-
-                       /* This code performs the actual conversion from a Triangle to an InstanceDescriptor. */
-                       public override object ConvertTo(ITypeDescriptorContext context, 
-                               System.Globalization.CultureInfo culture, object value, Type destinationType)
-                       {
-                               if (destinationType == typeof(InstanceDescriptor))
-                               {
-                                       ConstructorInfo ci = typeof(MySqlParameter).GetConstructor(
-                                               new Type[]{typeof(string), typeof(MySqlDbType), typeof(int), typeof(ParameterDirection),
-                                               typeof(bool), typeof(byte), typeof(byte), typeof(string), typeof(DataRowVersion),
-                                               typeof(object)});
-                                       MySqlParameter p = (MySqlParameter) value;
-                                       return new InstanceDescriptor(ci,new object[]{ 
-                                               p.ParameterName, p.DbType, p.Size, p.Direction, p.IsNullable, p.Precision,
-                                               p.Scale, p.SourceColumn, p.SourceVersion, p.Value});
-                               }
-
-                               // Always call base, even if you can't convert.
-                               return base.ConvertTo(context, culture, value, destinationType);
-                       }
-               }
-       }
-}
+// ByteFX.Data data access components for .Net\r
+// Copyright (C) 2002-2003  ByteFX, Inc.\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License, or (at your option) any later version.\r
+// \r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+// Lesser General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+\r
+using System;\r
+using System.Data;\r
+using System.Text;\r
+using System.ComponentModel;\r
+using System.ComponentModel.Design.Serialization;\r
+using System.Reflection;\r
+\r
+namespace ByteFX.Data.MySqlClient\r
+{\r
+       /// <summary>\r
+       /// Represents a parameter to a <see cref="MySqlCommand"/>, and optionally, its mapping to <see cref="DataSet"/> columns. This class cannot be inherited.\r
+       /// </summary>\r
+       [TypeConverter(typeof(MySqlParameter.MySqlParameterConverter))]\r
+       public sealed class MySqlParameter : MarshalByRefObject, IDataParameter, IDbDataParameter, ICloneable\r
+       {\r
+               private MySqlDbType                     dbType  = MySqlDbType.Null;\r
+               private DbType                          genericType;\r
+               private ParameterDirection      direction = ParameterDirection.Input;\r
+               private bool                            isNullable  = false;\r
+               private string                          paramName;\r
+               private string                          sourceColumn;\r
+               private DataRowVersion          sourceVersion = DataRowVersion.Current;\r
+               private object                          paramValue = DBNull.Value;\r
+               private int                                     size;\r
+               private byte                            precision=0, scale=0;\r
+\r
+               #region Constructors\r
+\r
+               /// <summary>\r
+               /// Initializes a new instance of the MySqlParameter class.\r
+               /// </summary>\r
+               public MySqlParameter()\r
+               {\r
+               }\r
+\r
+               /// <summary>\r
+               /// Initializes a new instance of the <see cref="MySqlParameter"/> class with the parameter name and a value of the new MySqlParameter.\r
+               /// </summary>\r
+               /// <param name="parameterName">The name of the parameter to map. </param>\r
+               /// <param name="value">An <see cref="Object"/> that is the value of the <see cref="MySqlParameter"/>. </param>\r
+               public MySqlParameter(string parameterName, object value)\r
+               {\r
+                       ParameterName = parameterName;\r
+                       paramValue = value;\r
+                       if (value is Byte[])\r
+                               size = (value as Byte[]).Length;\r
+                       dbType = GetMySqlType();\r
+                       genericType = GetGenericType();\r
+               }\r
+\r
+               /// <summary>\r
+               /// Initializes a new instance of the <see cref="MySqlParameter"/> class with the parameter name and the data type.\r
+               /// </summary>\r
+               /// <param name="parameterName">The name of the parameter to map. </param>\r
+               /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>\r
+               public MySqlParameter( string parameterName, MySqlDbType dbType)\r
+               {\r
+                       ParameterName = parameterName;\r
+                       this.dbType   = dbType;\r
+               }\r
+\r
+               /// <summary>\r
+               /// Initializes a new instance of the <see cref="MySqlParameter"/> class with the parameter name, the <see cref="MySqlDbType"/>, and the size.\r
+               /// </summary>\r
+               /// <param name="parameterName">The name of the parameter to map. </param>\r
+               /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>\r
+               /// <param name="size">The length of the parameter. </param>\r
+               public MySqlParameter( string parameterName, MySqlDbType dbType, int size )\r
+               {\r
+                       ParameterName = parameterName;\r
+                       this.dbType = dbType;\r
+                       this.size = size;\r
+               }\r
+\r
+               /// <summary>\r
+               /// Initializes a new instance of the <see cref="MySqlParameter"/> class with the parameter name, the <see cref="MySqlDbType"/>, the size, and the source column name.\r
+               /// </summary>\r
+               /// <param name="parameterName">The name of the parameter to map. </param>\r
+               /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>\r
+               /// <param name="size">The length of the parameter. </param>\r
+               /// <param name="sourceColumn">The name of the source column. </param>\r
+               public MySqlParameter( string parameterName, MySqlDbType dbType, int size, string sourceColumn )\r
+               {\r
+                       ParameterName = parameterName;\r
+                       this.dbType = dbType;\r
+                       this.size = size;\r
+                       this.direction = ParameterDirection.Input;\r
+                       this.precision = 0;\r
+                       this.scale = 0;\r
+                       this.sourceColumn = sourceColumn;\r
+                       this.sourceVersion = DataRowVersion.Current;\r
+                       this.paramValue =null;\r
+               }\r
+\r
+               internal MySqlParameter(string name, MySqlDbType type, ParameterDirection dir, string col, DataRowVersion ver, object val)\r
+               {\r
+                       if (direction != ParameterDirection.Input)\r
+                               throw new ArgumentException("Only input parameters are supported by MySql");\r
+                       dbType = type;\r
+                       direction = dir;\r
+                       ParameterName = name;\r
+                       sourceColumn = col;\r
+                       sourceVersion = ver;\r
+                       paramValue = val;\r
+               }\r
+\r
+               /// <summary>\r
+               /// Initializes a new instance of the <see cref="MySqlParameter"/> class with the parameter name, the type of the parameter, the size of the parameter, a <see cref="ParameterDirection"/>, the precision of the parameter, the scale of the parameter, the source column, a <see cref="DataRowVersion"/> to use, and the value of the parameter.\r
+               /// </summary>\r
+               /// <param name="parameterName">The name of the parameter to map. </param>\r
+               /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>\r
+               /// <param name="size">The length of the parameter. </param>\r
+               /// <param name="direction">One of the <see cref="ParameterDirection"/> values. </param>\r
+               /// <param name="isNullable">true if the value of the field can be null, otherwise false. </param>\r
+               /// <param name="precision">The total number of digits to the left and right of the decimal point to which <see cref="MySqlParameter.Value"/> is resolved.</param>\r
+               /// <param name="scale">The total number of decimal places to which <see cref="MySqlParameter.Value"/> is resolved. </param>\r
+               /// <param name="sourceColumn">The name of the source column. </param>\r
+               /// <param name="sourceVersion">One of the <see cref="DataRowVersion"/> values. </param>\r
+               /// <param name="value">An <see cref="Object"/> that is the value of the <see cref="MySqlParameter"/>. </param>\r
+               /// <exception cref="ArgumentException"/>\r
+               public MySqlParameter( string parameterName, MySqlDbType dbType, int size, ParameterDirection direction,\r
+                       bool isNullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion,\r
+                       object value)\r
+               {\r
+                       if (direction != ParameterDirection.Input)\r
+                               throw new ArgumentException("Only input parameters are supported by MySql");\r
+\r
+                       ParameterName = parameterName;\r
+                       this.dbType = dbType;\r
+                       this.size = size;\r
+                       this.direction = direction;\r
+                       this.precision = precision;\r
+                       this.scale = scale;\r
+                       this.sourceColumn = sourceColumn;\r
+                       this.sourceVersion = sourceVersion;\r
+                       this.paramValue = value;\r
+               }\r
+               #endregion\r
+\r
+               #region Properties\r
+\r
+               /// <summary>\r
+               /// Gets or sets the <see cref="DbType"/> of the parameter.\r
+               /// </summary>\r
+               public DbType DbType \r
+               {\r
+                       get \r
+                       { \r
+                               return genericType; \r
+                       }\r
+                       set \r
+                       { \r
+                               genericType = value; \r
+                               switch (genericType) \r
+                               {\r
+                                       case DbType.AnsiString:\r
+                                       case DbType.AnsiStringFixedLength:\r
+                                       case DbType.String:\r
+                                       case DbType.StringFixedLength:\r
+                                       case DbType.Guid:\r
+                                               MySqlDbType = MySqlDbType.VarChar; break;\r
+\r
+                                       case DbType.Byte:\r
+                                       case DbType.SByte:\r
+                                       case DbType.Boolean:\r
+                                               MySqlDbType = MySqlDbType.Byte; break;\r
+\r
+                                       case DbType.Int16:\r
+                                       case DbType.UInt16:\r
+                                               MySqlDbType = MySqlDbType.Short; break;\r
+\r
+                                       case DbType.Int32:\r
+                                       case DbType.UInt32:\r
+                                               MySqlDbType = MySqlDbType.Int; break;\r
+                                               \r
+                                       case DbType.Int64:\r
+                                       case DbType.UInt64:\r
+                                               MySqlDbType = MySqlDbType.BigInt; break;\r
+\r
+                                       case DbType.DateTime:\r
+                                               MySqlDbType = MySqlDbType.Datetime;     break;\r
+\r
+                                       case DbType.Date:\r
+                                               MySqlDbType = MySqlDbType.Date; break;\r
+\r
+                                       case DbType.Time:\r
+                                               MySqlDbType = MySqlDbType.Time; break;\r
+\r
+                                       case DbType.Single:\r
+                                               MySqlDbType = MySqlDbType.Float; break;\r
+                                       case DbType.Double:\r
+                                       case DbType.Currency:\r
+                                               MySqlDbType = MySqlDbType.Double; break;\r
+\r
+                                       case DbType.Decimal:\r
+                                       case DbType.VarNumeric:\r
+                                               MySqlDbType = MySqlDbType.Decimal; break;\r
+\r
+                                       case DbType.Binary:\r
+                                       case DbType.Object:\r
+                                               MySqlDbType = MySqlDbType.Blob; break;\r
+                               }\r
+                       }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets or sets a value indicating whether the parameter is input-only, output-only, bidirectional, or a stored procedure return value parameter.\r
+               /// As of MySql version 4.1 and earlier, input-only is the only valid choice.\r
+               /// </summary>\r
+               [Category("Data")]\r
+               public ParameterDirection Direction \r
+               {\r
+                       get { return direction; }\r
+                       set { direction = value; }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets or sets a value indicating whether the parameter accepts null values.\r
+               /// </summary>\r
+               [Browsable(false)]\r
+               public Boolean IsNullable \r
+               {\r
+                       get { return isNullable; }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets or sets the MySqlDbType of the parameter.\r
+               /// </summary>\r
+               [Category("Data")]\r
+               public MySqlDbType MySqlDbType \r
+               {\r
+                       get  \r
+                       { \r
+                               return dbType; \r
+                       }\r
+                       set  \r
+                       { \r
+                               dbType = value;  \r
+                       }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets or sets the name of the MySqlParameter.\r
+               /// </summary>\r
+               [Category("Misc")]\r
+               public String ParameterName \r
+               {\r
+                       get { return paramName; }\r
+                       set \r
+                       { \r
+                               paramName = value; \r
+                               if (paramName[0] == '@')\r
+                                       paramName = paramName.Substring(1, paramName.Length-1);\r
+                       }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets or sets the maximum number of digits used to represent the <see cref="Value"/> property.\r
+               /// </summary>\r
+               [Category("Data")]\r
+               public byte Precision \r
+               {\r
+                       get { return precision; }\r
+                       set { precision = value; }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets or sets the number of decimal places to which <see cref="Value"/> is resolved.\r
+               /// </summary>\r
+               [Category("Data")]\r
+               public byte Scale \r
+               {\r
+                       get { return scale; }\r
+                       set { scale = value; }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets or sets the maximum size, in bytes, of the data within the column.\r
+               /// </summary>\r
+               [Category("Data")]\r
+               public int Size \r
+               {\r
+                       get { return size; }\r
+                       set { size = value; }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets or sets the name of the source column that is mapped to the <see cref="DataSet"/> and used for loading or returning the <see cref="Value"/>.\r
+               /// </summary>\r
+               [Category("Data")]\r
+               public String SourceColumn \r
+               {\r
+                       get { return sourceColumn; }\r
+                       set { sourceColumn = value; }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets or sets the <see cref="DataRowVersion"/> to use when loading <see cref="Value"/>.\r
+               /// </summary>\r
+               [Category("Data")]\r
+               public DataRowVersion SourceVersion \r
+               {\r
+                       get { return sourceVersion; }\r
+                       set { sourceVersion = value; }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets or sets the value of the parameter.\r
+               /// </summary>\r
+               [TypeConverter(typeof(StringConverter))]\r
+               [Category("Data")]\r
+               public object Value \r
+               {\r
+                       get     { return paramValue; }\r
+                       set     \r
+                       { \r
+                               paramValue = value; \r
+                               if (dbType == MySqlDbType.Null) \r
+                               {\r
+                                       dbType = GetMySqlType();\r
+                                       genericType = GetGenericType();\r
+                               }\r
+                       }\r
+               }\r
+\r
+               #endregion\r
+\r
+               private void EscapeByteArray( byte[] bytes, System.IO.MemoryStream s )\r
+               {\r
+                       int theSize = size == 0 ? bytes.Length : size;\r
+                       byte[] newbytes = new byte[ theSize * 2 ];\r
+\r
+                       int newx=0;\r
+                       for (int x=0; x < theSize; x++)\r
+                       {\r
+                               byte b = bytes[x];\r
+                               if (b == '\0') \r
+                               {\r
+                                       newbytes[newx++] = (byte)'\\';\r
+                                       newbytes[newx++] = (byte)'0';\r
+                               }\r
+                               else \r
+                               {\r
+                                       if (b == '\\' || b == '\'' || b == '"' || b == '`' || b == '´')\r
+                                               newbytes[newx++] = (byte)'\\';\r
+                                       newbytes[newx++] = b;\r
+                               }\r
+                       }\r
+                       s.Write( newbytes, 0, newx );\r
+               }\r
+\r
+               /// <summary>\r
+               /// Overridden. Gets a string containing the <see cref="ParameterName"/>.\r
+               /// </summary>\r
+               /// <returns></returns>\r
+               public override string ToString() \r
+               {\r
+                       return paramName;\r
+               }\r
+\r
+               private string EscapeString( string s )\r
+               {\r
+                       s = s.Replace("\'", "\\\'");\r
+                       s = s.Replace("\"", "\\\"");\r
+                       return s;\r
+               }\r
+\r
+               internal void SerializeToBytes( System.IO.MemoryStream s, MySqlConnection conn )\r
+               {\r
+                       string  parm_string = null;\r
+                       byte[]  bytes = null;\r
+\r
+                       //TODO:  should value == null throw an exception?\r
+                       if (Value == DBNull.Value || Value == null)\r
+                               parm_string = "Null";\r
+                       else if (paramValue is bool)\r
+                               parm_string = Convert.ToByte(paramValue).ToString();\r
+                       else if (paramValue is Enum)\r
+                               parm_string = ((int)paramValue).ToString();\r
+                       else \r
+                       {\r
+                               switch (dbType) \r
+                               {\r
+                                       case MySqlDbType.Null:\r
+                                               parm_string = "Null";\r
+                                               break;\r
+\r
+                                       case MySqlDbType.VarChar:\r
+                                       case MySqlDbType.String:\r
+                                               parm_string = "'" + EscapeString(Value.ToString()) + "'";\r
+                                               break;\r
+\r
+                                       case MySqlDbType.Double:\r
+                                               parm_string = Convert.ToDouble(Value).ToString( conn.NumberFormat );\r
+                                               break;\r
+\r
+                                       case MySqlDbType.Float:\r
+                                               parm_string = Convert.ToSingle(Value).ToString( conn.NumberFormat );\r
+                                               break;\r
+\r
+                                       case MySqlDbType.Decimal:\r
+                                               parm_string = Convert.ToDecimal(Value).ToString( conn.NumberFormat );\r
+                                               break;\r
+\r
+                                       case MySqlDbType.Time:\r
+                                               if (Value is DateTime)\r
+                                                       parm_string = String.Format("'{0:HH:mm:ss}'", ((DateTime)Value));\r
+                                               else \r
+                                                       parm_string = String.Format("'{0}'", Value.ToString());\r
+                                               break;\r
+\r
+                                       case MySqlDbType.Date:\r
+                                               if (Value is DateTime)\r
+                                                       parm_string = String.Format("'{0:yyyy-MM-dd}'", ((DateTime)Value));\r
+                                               else \r
+                                                       parm_string = "'" + Value.ToString() + "'";\r
+                                               break;\r
+\r
+                                       case MySqlDbType.Datetime:\r
+                                               if (Value is DateTime)\r
+                                                       parm_string = String.Format("'{0:yyyy-MM-dd HH:mm:ss}'", ((DateTime)Value));\r
+                                               else\r
+                                                       parm_string = "'" + Value + "'";\r
+                                               break;\r
+\r
+                                       case MySqlDbType.Blob:\r
+                                       case MySqlDbType.MediumBlob:\r
+                                       case MySqlDbType.LongBlob:\r
+                                       case MySqlDbType.TinyBlob:\r
+                                               Type t = paramValue.GetType();\r
+\r
+                                               if (t == typeof(System.Byte[]))\r
+                                               {\r
+                                                       s.WriteByte((byte)'\'');\r
+                                                       EscapeByteArray( (byte[])paramValue, s );\r
+                                                       s.WriteByte((byte)'\'');\r
+                                                       return;\r
+                                               }\r
+                                               else if(t == typeof(string)) \r
+                                                       parm_string = "'" + EscapeString((string)paramValue) + "'";\r
+                                               else if (t == typeof(System.Guid))\r
+                                               {\r
+                                                       parm_string = "'" + paramValue.ToString() + "'";\r
+                                               }\r
+                                               break;\r
+\r
+                                       case MySqlDbType.Int:\r
+                                       case MySqlDbType.Int24:\r
+                                               parm_string = Convert.ToInt32( Value.ToString() ).ToString();\r
+                                               break;\r
+                               \r
+                                       case MySqlDbType.BigInt:\r
+                                               parm_string = Convert.ToInt64( Value.ToString() ).ToString();\r
+                                               break;\r
+\r
+                                       case MySqlDbType.Short:\r
+                                               parm_string = Convert.ToInt16( Value.ToString() ).ToString();\r
+                                               break;\r
+\r
+                                       default:\r
+                                               parm_string = Value.ToString();\r
+                                               break;\r
+                               }\r
+                       }\r
+\r
+                       bytes = conn.Encoding.GetBytes(parm_string);\r
+                       s.Write(bytes, 0, bytes.Length);\r
+               }\r
+\r
+               private DbType GetGenericType()\r
+               {\r
+                       if (paramValue is TimeSpan)\r
+                               return DbType.DateTime;\r
+                       if (paramValue is Enum)\r
+                               return DbType.Int32;\r
+                       if (paramValue is Guid)\r
+                               return DbType.String;\r
+\r
+                       switch ( Type.GetTypeCode(paramValue.GetType()) )\r
+                       {\r
+                               case TypeCode.Boolean: return DbType.Boolean;\r
+                               case TypeCode.Byte: return DbType.Byte;\r
+                               case TypeCode.Char: return DbType.StringFixedLength;\r
+                               case TypeCode.DateTime: return DbType.DateTime;\r
+                               case TypeCode.Decimal: return DbType.Decimal;\r
+                               case TypeCode.Double: return DbType.Double;\r
+                               case TypeCode.Int16: return DbType.Int16;\r
+                               case TypeCode.Int32: return DbType.Int32;\r
+                               case TypeCode.Int64: return DbType.Int64;\r
+                               case TypeCode.Object: return DbType.Binary;\r
+                               case TypeCode.SByte: return DbType.SByte;\r
+                               case TypeCode.Single: return DbType.Single;\r
+                               case TypeCode.String: return DbType.String;\r
+                               case TypeCode.UInt16: return DbType.UInt16;\r
+                               case TypeCode.UInt32: return DbType.UInt32;\r
+                               case TypeCode.UInt64: return DbType.UInt64;\r
+                       }\r
+                       return DbType.Object;\r
+               }\r
+\r
+               private MySqlDbType GetMySqlType()\r
+               {\r
+                       if (paramValue is System.TimeSpan)\r
+                               return MySqlDbType.Time;\r
+                       if (paramValue is Enum)\r
+                               return MySqlDbType.Int;\r
+                       if (paramValue is Guid)\r
+                               return MySqlDbType.String;\r
+\r
+                       switch (Type.GetTypeCode( paramValue.GetType() ))\r
+                       {\r
+                               case TypeCode.Empty:\r
+                                       throw new SystemException("Invalid data type");\r
+\r
+                               case TypeCode.Object: return MySqlDbType.Blob;\r
+                               case TypeCode.DBNull: return MySqlDbType.Null;\r
+                               case TypeCode.Char:\r
+                               case TypeCode.SByte:\r
+                               case TypeCode.Boolean:\r
+                               case TypeCode.Byte: return MySqlDbType.Byte;\r
+                               case TypeCode.Int16:\r
+                               case TypeCode.UInt16: return MySqlDbType.Int24;\r
+                               case TypeCode.Int32:\r
+                               case TypeCode.UInt32: return MySqlDbType.Int;\r
+                               case TypeCode.Int64:\r
+                               case TypeCode.UInt64: return MySqlDbType.BigInt;\r
+                               case TypeCode.Single: return MySqlDbType.Float;\r
+                               case TypeCode.Double: return MySqlDbType.Double;\r
+                               case TypeCode.Decimal: return MySqlDbType.Decimal;\r
+                               case TypeCode.DateTime: return MySqlDbType.Datetime;\r
+                               case TypeCode.String: return MySqlDbType.VarChar;\r
+\r
+                               default:\r
+                                       throw new SystemException("Value is of unknown data type");\r
+                       }\r
+               }\r
+\r
+\r
+               #region ICloneable\r
+               object System.ICloneable.Clone() \r
+               {\r
+                       MySqlParameter clone = new MySqlParameter( paramName, dbType, direction,\r
+                               sourceColumn, sourceVersion, paramValue );\r
+                       return clone;\r
+               }\r
+               #endregion\r
+\r
+               internal class MySqlParameterConverter : TypeConverter\r
+               {\r
+                       public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)\r
+                       {\r
+                               if (destinationType == typeof(InstanceDescriptor))\r
+                               {\r
+                                       return true;\r
+                               }\r
+\r
+                               // Always call the base to see if it can perform the conversion.\r
+                               return base.CanConvertTo(context, destinationType);\r
+                       }\r
+\r
+                       public override object ConvertTo(ITypeDescriptorContext context, \r
+                               System.Globalization.CultureInfo culture, object value, Type destinationType)\r
+                       {\r
+                               if (destinationType == typeof(InstanceDescriptor))\r
+                               {\r
+                                       ConstructorInfo ci = typeof(MySqlParameter).GetConstructor(\r
+                                               new Type[]{typeof(string), typeof(MySqlDbType), typeof(int), typeof(ParameterDirection),\r
+                                               typeof(bool), typeof(byte), typeof(byte), typeof(string), typeof(DataRowVersion),\r
+                                               typeof(object)});\r
+                                       MySqlParameter p = (MySqlParameter) value;\r
+                                       return new InstanceDescriptor(ci,new object[]{ \r
+                                               p.ParameterName, p.DbType, p.Size, p.Direction, p.IsNullable, p.Precision,\r
+                                               p.Scale, p.SourceColumn, p.SourceVersion, p.Value});\r
+                               }\r
+\r
+                               // Always call base, even if you can't convert.\r
+                               return base.ConvertTo(context, culture, value, destinationType);\r
+                       }\r
+               }\r
+       }\r
+}\r
index 84995140a4a39653a2210936a03912c5718ae66b..68eee7fe5593f31034d3c844f6c7679b7a28dfd2 100755 (executable)
-// ByteFX.Data data access components for .Net
-// Copyright (C) 2002-2003  ByteFX, Inc.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// 
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-// 
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-using System;
-using System.Data;
-using System.Collections;
-using System.ComponentModel;
-
-namespace ByteFX.Data.MySqlClient
-{
-       /// <summary>
-       /// Represents a collection of parameters relevant to a <see cref="MySqlCommand"/> as well as their respective mappings to columns in a <see cref="DataSet"/>. This class cannot be inherited.
-       /// </summary>
-       /// <include file='docs/MySqlParameterCollection.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>
-       [Editor(typeof(ByteFX.Data.Common.DBParametersEditor), typeof(System.Drawing.Design.UITypeEditor))]
-       [ListBindable(true)]
-       public sealed class MySqlParameterCollection : MarshalByRefObject, IDataParameterCollection, 
-               IList, ICollection, IEnumerable
-       {
-               private ArrayList       _parms = new ArrayList();
-
-               #region ICollection support
-
-               /// <summary>
-               /// Gets the number of MySqlParameter objects in the collection.
-               /// </summary>
-               public int Count 
-               {
-                       get { return _parms.Count; }
-               }
-
-               /// <summary>
-               /// Copies MySqlParameter objects from the MySqlParameterCollection to the specified array.
-               /// </summary>
-               /// <param name="array"></param>
-               /// <param name="index"></param>
-               public void CopyTo( Array array, int index ) 
-               {
-                       _parms.CopyTo(array, index);
-               }
-
-               bool ICollection.IsSynchronized
-               {
-                       get { return _parms.IsSynchronized; }
-               }
-
-               object ICollection.SyncRoot
-               {
-                       get { return _parms.SyncRoot; }
-               }
-               #endregion
-
-               #region IList
-
-               /// <summary>
-               /// Removes all items from the collection.
-               /// </summary>
-               public void Clear()
-               {
-                       _parms.Clear();
-               }
-
-               /// <summary>
-               /// Gets a value indicating whether a MySqlParameter exists in the collection.
-               /// </summary>
-               /// <param name="value">The value of the <see cref="MySqlParameter"/> object to find. </param>
-               /// <returns>true if the collection contains the <see cref="MySqlParameter"/> object; otherwise, false.</returns>
-               /// <overloads>Gets a value indicating whether a <see cref="MySqlParameter"/> exists in the collection.</overloads>
-               public bool Contains(object value)
-               {
-                       return _parms.Contains(value);
-               }
-
-               /// <summary>
-               /// Gets the location of a <see cref="MySqlParameter"/> in the collection.
-               /// </summary>
-               /// <param name="value">The <see cref="MySqlParameter"/> object to locate. </param>
-               /// <returns>The zero-based location of the <see cref="MySqlParameter"/> in the collection.</returns>
-               /// <overloads>Gets the location of a <see cref="MySqlParameter"/> in the collection.</overloads>
-               public int IndexOf(object value)
-               {
-                       return _parms.IndexOf(value);
-               }
-
-               /// <summary>
-               /// Inserts a MySqlParameter into the collection at the specified index.
-               /// </summary>
-               /// <param name="index"></param>
-               /// <param name="value"></param>
-               public void Insert(int index, object value)
-               {
-                       _parms.Insert( index, value );
-               }
-
-               bool IList.IsFixedSize
-               {
-                       get { return _parms.IsFixedSize; }
-               }
-
-               bool IList.IsReadOnly
-               {
-                       get { return _parms.IsReadOnly; }
-               }
-
-               /// <summary>
-               /// Removes the specified MySqlParameter from the collection.
-               /// </summary>
-               /// <param name="value"></param>
-               public void Remove( object value )
-               {
-                       _parms.Remove( value );
-               }
-
-               /// <summary>
-               /// Removes the specified <see cref="MySqlParameter"/> from the collection using a specific index.
-               /// </summary>
-               /// <param name="index">The zero-based index of the parameter. </param>
-               /// <overloads>Removes the specified <see cref="MySqlParameter"/> from the collection.</overloads>
-               public void RemoveAt( int index )
-               {
-                       _parms.RemoveAt( index );
-               }
-
-               object IList.this[int index] 
-               {
-                       get { return this[index]; }
-                       set 
-                       { 
-                               if (! (value is MySqlParameter)) throw new MySqlException("Only MySqlParameter objects may be stored");
-                               this[index] = (MySqlParameter)value; 
-                       }
-               }
-
-               /// <summary>
-               /// Adds the specified <see cref="MySqlParameter"/> object to the <see cref="MySqlParameterCollection"/>.
-               /// </summary>
-               /// <param name="value">The <see cref="MySqlParameter"/> to add to the collection.</param>
-               /// <returns>The index of the new <see cref="MySqlParameter"/> object.</returns>
-               public int Add( object value )
-               {
-                       if (! (value is MySqlParameter)) throw new MySqlException("Only MySqlParameter objects may be stored");
-
-                       MySqlParameter p = (MySqlParameter)value;
-
-                       if (p.ParameterName == null || p.ParameterName == String.Empty)
-                               throw new MySqlException("Parameters must be named");
-
-                       return _parms.Add(value);
-               }
-
-               #endregion
-
-               #region IDataParameterCollection
-
-               /// <summary>
-               /// Gets a value indicating whether a <see cref="MySqlParameter"/> with the specified parameter name exists in the collection.
-               /// </summary>
-               /// <param name="name">The name of the <see cref="MySqlParameter"/> object to find.</param>
-               /// <returns>true if the collection contains the parameter; otherwise, false.</returns>
-               public bool Contains(string name)
-               {
-                       if (name[0] == '@')
-                               name = name.Substring(1, name.Length-1);
-                       foreach (MySqlParameter p in _parms)
-                       {
-                               if (p.ParameterName.ToLower().Equals( name.ToLower() )) return true;
-                       }
-                       return false;
-               }
-
-               /// <summary>
-               /// Gets the location of the <see cref="MySqlParameter"/> in the collection with a specific parameter name.
-               /// </summary>
-               /// <param name="parameterName">The name of the <see cref="MySqlParameter"/> object to retrieve. </param>
-               /// <returns>The zero-based location of the <see cref="MySqlParameter"/> in the collection.</returns>
-               public int IndexOf( string parameterName )
-               {
-                       if (parameterName[0] == '@')
-                               parameterName = parameterName.Substring(1, parameterName.Length-1);
-                       for (int x=0; x < _parms.Count; x++) 
-                       {
-                               MySqlParameter p = (MySqlParameter)_parms[x];
-                               if (p.ParameterName.ToLower().Equals( parameterName.ToLower() )) return x;
-                       }
-                       throw new MySqlException("Parameter '" + parameterName + "' not found in collection");
-               }
-
-               /// <summary>
-               /// Removes the specified <see cref="MySqlParameter"/> from the collection using the parameter name.
-               /// </summary>
-               /// <param name="name">The name of the <see cref="MySqlParameter"/> object to retrieve. </param>
-               public void RemoveAt( string name )
-               {
-                       int index = IndexOf( name );
-                       _parms.RemoveAt(index);
-               }
-
-               object IDataParameterCollection.this[string name]
-               {
-                       get { return this[name]; }
-                       set 
-                       { 
-                               if (! (value is MySqlParameter)) throw new MySqlException("Only MySqlParameter objects may be stored");
-                               this[name] = (MySqlParameter)value;
-                       }
-               }
-               #endregion
-
-               #region IEnumerable
-               IEnumerator IEnumerable.GetEnumerator()
-               {
-                       return ((IEnumerable)_parms).GetEnumerator();
-               }
-               #endregion
-
-               #region Public Methods
-
-               /// <summary>
-               /// Gets the <see cref="MySqlParameter"/> at the specified index.
-               /// </summary>
-               /// <overloads>Gets the <see cref="MySqlParameter"/> with a specified attribute.
-               /// [C#] In C#, this property is the indexer for the <see cref="MySqlParameterCollection"/> class.
-               /// </overloads>
-               public MySqlParameter this[int index]
-               {
-                       get { return (MySqlParameter)_parms[index]; }
-                       set { _parms[index] = value; }
-               }
-
-               /// <summary>
-               /// Gets the <see cref="MySqlParameter"/> with the specified name.
-               /// </summary>
-               public MySqlParameter this[string name]
-               {
-                       get { return (MySqlParameter)_parms[ IndexOf( name ) ]; }
-                       set { _parms[ IndexOf( name ) ] = value; }
-               }
-
-               /// <summary>
-               /// Adds the specified <see cref="MySqlParameter"/> object to the <see cref="MySqlParameterCollection"/>.
-               /// </summary>
-               /// <param name="value">The <see cref="MySqlParameter"/> to add to the collection.</param>
-               /// <returns>The index of the new <see cref="MySqlParameter"/> object.</returns>
-               public MySqlParameter Add(MySqlParameter value)
-               {
-                       if ( value.ParameterName == null ) throw new ArgumentException("parameter must be named");
-
-                       _parms.Add(value);
-                       return value;
-               }
-
-               /// <summary>
-               /// Adds a <see cref="MySqlParameter"/> to the <see cref="MySqlParameterCollection"/> given the specified parameter name and value.
-               /// </summary>
-               /// <param name="parameterName">The name of the parameter.</param>
-               /// <param name="value">The <see cref="MySqlParameter.Value"/> of the <see cref="MySqlParameter"/> to add to the collection.</param>
-               /// <returns>The index of the new <see cref="MySqlParameter"/> object.</returns>
-               public MySqlParameter Add( string parameterName, object value )
-               {
-                       return Add( new MySqlParameter( parameterName, value ) );
-               }
-
-               /// <summary>
-               /// Adds a <see cref="MySqlParameter"/> to the <see cref="MySqlParameterCollection"/> given the parameter name and the data type.
-               /// </summary>
-               /// <param name="parameterName">The name of the parameter.</param>
-               /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
-               /// <returns>The index of the new <see cref="MySqlParameter"/> object.</returns>
-               public MySqlParameter Add(string parameterName, MySqlDbType dbType)
-               {
-                       return Add(new MySqlParameter(parameterName, dbType));
-               }
-
-               /// <summary>
-               /// Adds a <see cref="MySqlParameter"/> to the <see cref="MySqlParameterCollection"/> with the parameter name, the data type, and the column length.
-               /// </summary>
-               /// <param name="parameterName">The name of the parameter.</param>
-               /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
-               /// <param name="size">The length of the column.</param>
-               /// <returns>The index of the new <see cref="MySqlParameter"/> object.</returns>
-               public MySqlParameter Add(string parameterName, MySqlDbType dbType, int size)
-               {
-                       return Add(new MySqlParameter(parameterName, dbType, size ));
-               }
-
-               /// <summary>
-               /// Adds a <see cref="MySqlParameter"/> to the <see cref="MySqlParameterCollection"/> with the parameter name, the data type, the column length, and the source column name.
-               /// </summary>
-               /// <param name="parameterName">The name of the parameter.</param>
-               /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
-               /// <param name="size">The length of the column.</param>
-               /// <param name="sourceColumn">The name of the source column.</param>
-               /// <returns>The index of the new <see cref="MySqlParameter"/> object.</returns>
-               public MySqlParameter Add(string parameterName, MySqlDbType dbType, int size, string sourceColumn)
-               {
-                       return Add(new MySqlParameter(parameterName, dbType, size, sourceColumn));
-               }
-
-               #endregion
-
-       }
-}
+// ByteFX.Data data access components for .Net\r
+// Copyright (C) 2002-2003  ByteFX, Inc.\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License, or (at your option) any later version.\r
+// \r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+// Lesser General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+\r
+using System;\r
+using System.Data;\r
+using System.Collections;\r
+using System.ComponentModel;\r
+\r
+namespace ByteFX.Data.MySqlClient\r
+{\r
+       /// <summary>\r
+       /// Represents a collection of parameters relevant to a <see cref="MySqlCommand"/> as well as their respective mappings to columns in a <see cref="DataSet"/>. This class cannot be inherited.\r
+       /// </summary>\r
+       /// <include file='docs/MySqlParameterCollection.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>\r
+       [Editor(typeof(ByteFX.Data.Common.DBParametersEditor), typeof(System.Drawing.Design.UITypeEditor))]\r
+       [ListBindable(true)]\r
+       public sealed class MySqlParameterCollection : MarshalByRefObject, IDataParameterCollection, \r
+               IList, ICollection, IEnumerable\r
+       {\r
+               private ArrayList       _parms = new ArrayList();\r
+\r
+               #region ICollection support\r
+\r
+               /// <summary>\r
+               /// Gets the number of MySqlParameter objects in the collection.\r
+               /// </summary>\r
+               public int Count \r
+               {\r
+                       get { return _parms.Count; }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Copies MySqlParameter objects from the MySqlParameterCollection to the specified array.\r
+               /// </summary>\r
+               /// <param name="array"></param>\r
+               /// <param name="index"></param>\r
+               public void CopyTo( Array array, int index ) \r
+               {\r
+                       _parms.CopyTo(array, index);\r
+               }\r
+\r
+               bool ICollection.IsSynchronized\r
+               {\r
+                       get { return _parms.IsSynchronized; }\r
+               }\r
+\r
+               object ICollection.SyncRoot\r
+               {\r
+                       get { return _parms.SyncRoot; }\r
+               }\r
+               #endregion\r
+\r
+               #region IList\r
+\r
+               /// <summary>\r
+               /// Removes all items from the collection.\r
+               /// </summary>\r
+               public void Clear()\r
+               {\r
+                       _parms.Clear();\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets a value indicating whether a MySqlParameter exists in the collection.\r
+               /// </summary>\r
+               /// <param name="value">The value of the <see cref="MySqlParameter"/> object to find. </param>\r
+               /// <returns>true if the collection contains the <see cref="MySqlParameter"/> object; otherwise, false.</returns>\r
+               /// <overloads>Gets a value indicating whether a <see cref="MySqlParameter"/> exists in the collection.</overloads>\r
+               public bool Contains(object value)\r
+               {\r
+                       return _parms.Contains(value);\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the location of a <see cref="MySqlParameter"/> in the collection.\r
+               /// </summary>\r
+               /// <param name="value">The <see cref="MySqlParameter"/> object to locate. </param>\r
+               /// <returns>The zero-based location of the <see cref="MySqlParameter"/> in the collection.</returns>\r
+               /// <overloads>Gets the location of a <see cref="MySqlParameter"/> in the collection.</overloads>\r
+               public int IndexOf(object value)\r
+               {\r
+                       return _parms.IndexOf(value);\r
+               }\r
+\r
+               /// <summary>\r
+               /// Inserts a MySqlParameter into the collection at the specified index.\r
+               /// </summary>\r
+               /// <param name="index"></param>\r
+               /// <param name="value"></param>\r
+               public void Insert(int index, object value)\r
+               {\r
+                       _parms.Insert( index, value );\r
+               }\r
+\r
+               bool IList.IsFixedSize\r
+               {\r
+                       get { return _parms.IsFixedSize; }\r
+               }\r
+\r
+               bool IList.IsReadOnly\r
+               {\r
+                       get { return _parms.IsReadOnly; }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Removes the specified MySqlParameter from the collection.\r
+               /// </summary>\r
+               /// <param name="value"></param>\r
+               public void Remove( object value )\r
+               {\r
+                       _parms.Remove( value );\r
+               }\r
+\r
+               /// <summary>\r
+               /// Removes the specified <see cref="MySqlParameter"/> from the collection using a specific index.\r
+               /// </summary>\r
+               /// <param name="index">The zero-based index of the parameter. </param>\r
+               /// <overloads>Removes the specified <see cref="MySqlParameter"/> from the collection.</overloads>\r
+               public void RemoveAt( int index )\r
+               {\r
+                       _parms.RemoveAt( index );\r
+               }\r
+\r
+               object IList.this[int index] \r
+               {\r
+                       get { return this[index]; }\r
+                       set \r
+                       { \r
+                               if (! (value is MySqlParameter)) throw new MySqlException("Only MySqlParameter objects may be stored");\r
+                               this[index] = (MySqlParameter)value; \r
+                       }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Adds the specified <see cref="MySqlParameter"/> object to the <see cref="MySqlParameterCollection"/>.\r
+               /// </summary>\r
+               /// <param name="value">The <see cref="MySqlParameter"/> to add to the collection.</param>\r
+               /// <returns>The index of the new <see cref="MySqlParameter"/> object.</returns>\r
+               public int Add( object value )\r
+               {\r
+                       if (! (value is MySqlParameter)) throw new MySqlException("Only MySqlParameter objects may be stored");\r
+\r
+                       MySqlParameter p = (MySqlParameter)value;\r
+\r
+                       if (p.ParameterName == null || p.ParameterName == String.Empty)\r
+                               throw new MySqlException("Parameters must be named");\r
+\r
+                       return _parms.Add(value);\r
+               }\r
+\r
+               #endregion\r
+\r
+               #region IDataParameterCollection\r
+\r
+               /// <summary>\r
+               /// Gets a value indicating whether a <see cref="MySqlParameter"/> with the specified parameter name exists in the collection.\r
+               /// </summary>\r
+               /// <param name="name">The name of the <see cref="MySqlParameter"/> object to find.</param>\r
+               /// <returns>true if the collection contains the parameter; otherwise, false.</returns>\r
+               public bool Contains(string name)\r
+               {\r
+                       if (name[0] == '@')\r
+                               name = name.Substring(1, name.Length-1);\r
+                       foreach (MySqlParameter p in _parms)\r
+                       {\r
+                               if (p.ParameterName.ToLower().Equals( name.ToLower() )) return true;\r
+                       }\r
+                       return false;\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the location of the <see cref="MySqlParameter"/> in the collection with a specific parameter name.\r
+               /// </summary>\r
+               /// <param name="parameterName">The name of the <see cref="MySqlParameter"/> object to retrieve. </param>\r
+               /// <returns>The zero-based location of the <see cref="MySqlParameter"/> in the collection.</returns>\r
+               public int IndexOf( string parameterName )\r
+               {\r
+                       if (parameterName[0] == '@')\r
+                               parameterName = parameterName.Substring(1, parameterName.Length-1);\r
+                       for (int x=0; x < _parms.Count; x++) \r
+                       {\r
+                               MySqlParameter p = (MySqlParameter)_parms[x];\r
+                               if (p.ParameterName.ToLower().Equals( parameterName.ToLower() )) return x;\r
+                       }\r
+                       throw new MySqlException("Parameter '" + parameterName + "' not found in collection");\r
+               }\r
+\r
+               /// <summary>\r
+               /// Removes the specified <see cref="MySqlParameter"/> from the collection using the parameter name.\r
+               /// </summary>\r
+               /// <param name="name">The name of the <see cref="MySqlParameter"/> object to retrieve. </param>\r
+               public void RemoveAt( string name )\r
+               {\r
+                       int index = IndexOf( name );\r
+                       _parms.RemoveAt(index);\r
+               }\r
+\r
+               object IDataParameterCollection.this[string name]\r
+               {\r
+                       get { return this[name]; }\r
+                       set \r
+                       { \r
+                               if (! (value is MySqlParameter)) throw new MySqlException("Only MySqlParameter objects may be stored");\r
+                               this[name] = (MySqlParameter)value;\r
+                       }\r
+               }\r
+               #endregion\r
+\r
+               #region IEnumerable\r
+               IEnumerator IEnumerable.GetEnumerator()\r
+               {\r
+                       return ((IEnumerable)_parms).GetEnumerator();\r
+               }\r
+               #endregion\r
+\r
+               #region Public Methods\r
+\r
+               /// <summary>\r
+               /// Gets the <see cref="MySqlParameter"/> at the specified index.\r
+               /// </summary>\r
+               /// <overloads>Gets the <see cref="MySqlParameter"/> with a specified attribute.\r
+               /// [C#] In C#, this property is the indexer for the <see cref="MySqlParameterCollection"/> class.\r
+               /// </overloads>\r
+               public MySqlParameter this[int index]\r
+               {\r
+                       get { return (MySqlParameter)_parms[index]; }\r
+                       set { _parms[index] = value; }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the <see cref="MySqlParameter"/> with the specified name.\r
+               /// </summary>\r
+               public MySqlParameter this[string name]\r
+               {\r
+                       get { return (MySqlParameter)_parms[ IndexOf( name ) ]; }\r
+                       set { _parms[ IndexOf( name ) ] = value; }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Adds the specified <see cref="MySqlParameter"/> object to the <see cref="MySqlParameterCollection"/>.\r
+               /// </summary>\r
+               /// <param name="value">The <see cref="MySqlParameter"/> to add to the collection.</param>\r
+               /// <returns>The index of the new <see cref="MySqlParameter"/> object.</returns>\r
+               public MySqlParameter Add(MySqlParameter value)\r
+               {\r
+                       if ( value.ParameterName == null ) throw new ArgumentException("parameter must be named");\r
+\r
+                       _parms.Add(value);\r
+                       return value;\r
+               }\r
+\r
+               /// <summary>\r
+               /// Adds a <see cref="MySqlParameter"/> to the <see cref="MySqlParameterCollection"/> given the specified parameter name and value.\r
+               /// </summary>\r
+               /// <param name="parameterName">The name of the parameter.</param>\r
+               /// <param name="value">The <see cref="MySqlParameter.Value"/> of the <see cref="MySqlParameter"/> to add to the collection.</param>\r
+               /// <returns>The index of the new <see cref="MySqlParameter"/> object.</returns>\r
+               public MySqlParameter Add( string parameterName, object value )\r
+               {\r
+                       return Add( new MySqlParameter( parameterName, value ) );\r
+               }\r
+\r
+               /// <summary>\r
+               /// Adds a <see cref="MySqlParameter"/> to the <see cref="MySqlParameterCollection"/> given the parameter name and the data type.\r
+               /// </summary>\r
+               /// <param name="parameterName">The name of the parameter.</param>\r
+               /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>\r
+               /// <returns>The index of the new <see cref="MySqlParameter"/> object.</returns>\r
+               public MySqlParameter Add(string parameterName, MySqlDbType dbType)\r
+               {\r
+                       return Add(new MySqlParameter(parameterName, dbType));\r
+               }\r
+\r
+               /// <summary>\r
+               /// Adds a <see cref="MySqlParameter"/> to the <see cref="MySqlParameterCollection"/> with the parameter name, the data type, and the column length.\r
+               /// </summary>\r
+               /// <param name="parameterName">The name of the parameter.</param>\r
+               /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>\r
+               /// <param name="size">The length of the column.</param>\r
+               /// <returns>The index of the new <see cref="MySqlParameter"/> object.</returns>\r
+               public MySqlParameter Add(string parameterName, MySqlDbType dbType, int size)\r
+               {\r
+                       return Add(new MySqlParameter(parameterName, dbType, size ));\r
+               }\r
+\r
+               /// <summary>\r
+               /// Adds a <see cref="MySqlParameter"/> to the <see cref="MySqlParameterCollection"/> with the parameter name, the data type, the column length, and the source column name.\r
+               /// </summary>\r
+               /// <param name="parameterName">The name of the parameter.</param>\r
+               /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>\r
+               /// <param name="size">The length of the column.</param>\r
+               /// <param name="sourceColumn">The name of the source column.</param>\r
+               /// <returns>The index of the new <see cref="MySqlParameter"/> object.</returns>\r
+               public MySqlParameter Add(string parameterName, MySqlDbType dbType, int size, string sourceColumn)\r
+               {\r
+                       return Add(new MySqlParameter(parameterName, dbType, size, sourceColumn));\r
+               }\r
+\r
+               #endregion\r
+\r
+       }\r
+}\r
diff --git a/mcs/class/ByteFX.Data/mysqlclient/resources/command.bmp b/mcs/class/ByteFX.Data/mysqlclient/resources/command.bmp
new file mode 100644 (file)
index 0000000..5b007f8
Binary files /dev/null and b/mcs/class/ByteFX.Data/mysqlclient/resources/command.bmp differ
diff --git a/mcs/class/ByteFX.Data/mysqlclient/resources/connection.bmp b/mcs/class/ByteFX.Data/mysqlclient/resources/connection.bmp
new file mode 100644 (file)
index 0000000..559302c
Binary files /dev/null and b/mcs/class/ByteFX.Data/mysqlclient/resources/connection.bmp differ
diff --git a/mcs/class/ByteFX.Data/mysqlclient/resources/dataadapter.bmp b/mcs/class/ByteFX.Data/mysqlclient/resources/dataadapter.bmp
new file mode 100644 (file)
index 0000000..7fb4820
Binary files /dev/null and b/mcs/class/ByteFX.Data/mysqlclient/resources/dataadapter.bmp differ
index e55a098068374bae27a84a132146923b00a34044..2dc9c0289186ef56ff0b4cb0f7714af35e41cb88 100755 (executable)
@@ -1,27 +1 @@
-0.65
-====================
-[done]Protocol compression
-[done]Support for GetSchemaTable
-[done]Named pipes for Windows working
-[done]Fix issue with ASP.Net data grid  
-[done]Transactions
-[done]Fixed date/time handling
-MySqlCommandBuilder
-0.7
-=================================
-Support for all CommandBehaviors
-make XSD internal only
-Different character sets
-
-0.8
-================================
-Designer support for MySqlCommandBuilder
-
-0.9
-===============================
-?????
-
-1.0
-====================
-Oh yeah!
\ No newline at end of file
+1.  implement connect timeout in ConnectionInternal\r
diff --git a/mcs/class/ByteFX.Data/mysqlclient/transaction.cs b/mcs/class/ByteFX.Data/mysqlclient/transaction.cs
new file mode 100644 (file)
index 0000000..bc034ab
--- /dev/null
@@ -0,0 +1,106 @@
+// ByteFX.Data data access components for .Net\r
+// Copyright (C) 2002-2003  ByteFX, Inc.\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License, or (at your option) any later version.\r
+// \r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+// Lesser General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+\r
+using System;\r
+using System.Data;\r
+\r
+namespace ByteFX.Data.MySqlClient\r
+{\r
+       /// <summary>\r
+       /// Represents a SQL transaction to be made in a MySQL database. This class cannot be inherited.\r
+       /// </summary>\r
+       /// <include file='docs/MySqlTransaction.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>\r
+       public sealed class MySqlTransaction : IDbTransaction\r
+       {\r
+               private IsolationLevel  _level;\r
+               private MySqlConnection _conn;\r
+               private bool                    _open;\r
+\r
+               internal MySqlTransaction() \r
+               {\r
+                       _open = true;\r
+               }\r
+\r
+               #region Properties\r
+\r
+               /// <summary>\r
+               /// Gets the <see cref="MySqlConnection"/> object associated with the transaction, or a null reference (Nothing in Visual Basic) if the transaction is no longer valid.\r
+               /// </summary>\r
+               public IDbConnection Connection\r
+               {\r
+                       get { return _conn;     } \r
+                       set { _conn = (MySqlConnection)value; }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Specifies the <see cref="IsolationLevel"/> for this transaction.\r
+               /// </summary>\r
+               public IsolationLevel IsolationLevel \r
+               {\r
+                       get { return _level; }\r
+                       set { _level = value; }\r
+               }\r
+\r
+               #endregion\r
+\r
+               void System.IDisposable.Dispose() \r
+               {\r
+               }\r
+\r
+               /// <summary>\r
+               /// Commits the database transaction.\r
+               /// </summary>\r
+               public void Commit()\r
+               {\r
+                       if (_conn == null || _conn.State != ConnectionState.Open)\r
+                               throw new InvalidOperationException("Connection must be valid and open to commit transaction");\r
+                       if (!_open)\r
+                               throw new InvalidOperationException("Transaction has already been committed or is not pending");\r
+                       Driver d = _conn.InternalConnection.Driver;\r
+                       try \r
+                       {\r
+                               d.Send(DBCmd.QUERY, "COMMIT");\r
+                               _open = false;\r
+                       }\r
+                       catch (MySqlException ex) \r
+                       {\r
+                               throw ex;\r
+                       }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Overloaded. Rolls back a transaction from a pending state.\r
+               /// </summary>\r
+               public void Rollback()\r
+               {\r
+                       if (_conn == null || _conn.State != ConnectionState.Open)\r
+                               throw new InvalidOperationException("Connection must be valid and open to commit transaction");\r
+                       if (!_open)\r
+                               throw new InvalidOperationException("Transaction has already been rolled back or is not pending");\r
+                       Driver d = _conn.InternalConnection.Driver;\r
+                       try \r
+                       {\r
+                               d.Send(DBCmd.QUERY, "ROLLBACK");\r
+                               _open = false;\r
+                       }\r
+                       catch (MySqlException ex) \r
+                       {\r
+                               throw ex;\r
+                       }\r
+               }\r
+       }\r
+}\r
index 3b66843ed0f5b2b2cf0d385e93d05f19856e0577..a6fb43b5ab05b590186b0133704c99b2415f260d 100755 (executable)
@@ -1,41 +1,59 @@
-Managed Drivers for MySQL and PostgreSQL
-======================================
-
-Current Status of MySQL driver
-----------------------------------
-The driver is currently under heavy development.
-The driver is in beta form with most features working reasonably well.
-
-** Please note that the binaries distributed in the package are either
-compiled with Mono or .NET 1.1. **
-
-
-Current status of the PostgreSQL driver
----------------------------------------
-The PostgreSQL driver is just starting and not really usable yet. 
-It can perform simple reads with a limited set of data types.
-Watch the project over the next few weeks to see much 
-improvement.
-
-
-Credit
----------------------------------------
-First of all, many thanks to the MySQL folks for creating such a great database.
-
-Next, I have to give a big thanks and kudos to Mark Matthews for his Java-based MySQL driver.
-As the protocol to MySQL is very poorly documented, his driver proved to be invaluable.
-
-Also, I have to give thanks for Jun Su for starting the SourceForge project and for his wonderful
-contribution of code and ideas.
-
-Thanks also go out to Peter Belbin, Timoth Parez, and Daniel Morgan for their input, testing, and all
-the other things that make open source projects successful!
-
-I have started putting the names of people who post bugs, patches, suggestions, or anything else of value to the changelog.
-If you have posted and don't see your name, I apologize.  Please let me know who you are and I'll include you.
-The most important thing here is to understand that this is not a one man show.  So many people have provided input
-along the way.
-
-
-
-
+Managed Drivers for MySQL and PostgreSQL\r
+======================================\r
+\r
+Current Status of MySQL driver\r
+----------------------------------\r
+The driver is currently under heavy development.\r
+The driver is in beta form with most features working reasonably well.\r
+\r
+** Please note that the binaries distributed in the package are either\r
+compiled with Mono or .NET 1.1. **\r
+\r
+\r
+Current status of the PostgreSQL driver\r
+---------------------------------------\r
+The PostgreSQL driver is just starting and not really usable yet. \r
+It can perform simple reads with a limited set of data types.\r
+Watch the project over the next few weeks to see much \r
+improvement.\r
+\r
+\r
+Credit\r
+---------------------------------------\r
+First of all, many thanks to the MySQL folks for creating such a great database.\r
+\r
+Next, I have to give a big thanks and kudos to Mark Matthews for his Java-based MySQL driver.\r
+As the protocol to MySQL is very poorly documented, his driver proved to be invaluable.\r
+\r
+Also, I have to give thanks for Jun Su for starting the SourceForge project and for his wonderful\r
+contribution of code and ideas.\r
+\r
+The following people have also contributed and their additions have been greatly appreciated.\r
+=================\r
+Timothy Parez\r
+Peter Belbin\r
+Daniel Guisinger\r
+Steve M. Brown\r
+Clint Kennedy\r
+Matthew J. Peddlesden\r
+Daniel Morgan\r
+Rory Plaire\r
+Marco Poponi\r
+Mark Reay\r
+\r
+....just to name a few.  Many people have contributed either through code, testing, or bug reports.  If I have left\r
+your name off, it is not intentional and I apologize.  Thank you to everyone who has contributed and continues\r
+to contribute to this project.\r
+\r
+\r
+I have started putting the names of people who post bugs, patches, suggestions, or anything else of value to the changelog.\r
+If you have posted and don't see your name, I apologize.  Please let me know who you are and I'll include you.\r
+The most important thing here is to understand that this is not a one man show.  So many people have provided input\r
+along the way.\r
+\r
+Reggie Burnett\r
+ByteFX, Inc.\r
+\r
+\r
+\r
+\r