[Quantproject-developers] QuantProject/b2_DataAccess DataBase.cs, 1.13, 1.14
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2009-01-11 20:16:42
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv15676/b2_DataAccess Modified Files: DataBase.cs Log Message: A new boolean method has been added to detect if a given exception is due to an attempt to insert a record that would lead to a duplicate a key in the database Index: DataBase.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/DataBase.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** DataBase.cs 30 Dec 2008 00:11:44 -0000 1.13 --- DataBase.cs 11 Jan 2009 20:16:35 -0000 1.14 *************** *** 29,32 **** --- 29,34 ---- using System.Windows.Forms; + using MySql.Data.MySqlClient; + using QuantProject.ADT; using QuantProject.ADT.Histories; *************** *** 308,311 **** --- 310,337 ---- } #endregion GetBarOpenHistory + + /// <summary> + /// true iif exception is risen by the attempt to duplicate a value in + /// a table + /// </summary> + /// <param name="exception"></param> + /// <returns></returns> + public static bool IsExceptionForForbiddenDataDuplication( + Exception exception ) + { + bool isExceptionForForbiddenDataDuplication = + ( + ( + ( exception is OleDbException ) && + exception.Message.Contains( "duplicate values" ) + ) + || + ( + ( exception is MySqlException ) && + exception.Message.Contains( "Duplicate entry" ) + ) + ); + return isExceptionForForbiddenDataDuplication; + } } } |