private void oleDBda_RowUpdating(object sender, OleDbRowUpdatingEventArgs e)
		{
			Exception exp = null;
			switch (e.StatementType)
			{
				case StatementType.Insert: 
					try
					{
						BeginCase("RowInsert");
						Compare(drInsert ,e.Row );
					}
					catch(Exception ex)	{exp = ex;}
					finally	{EndCase(exp); exp = null;}
					EventCounter++;
					break;
				case StatementType.Delete:
					try
					{
						BeginCase("RowDelete");
						Compare(drDelete ,e.Row );
					}
					catch(Exception ex)	{exp = ex;}
					finally	{EndCase(exp); exp = null;}
					EventCounter++;
					break;
				case StatementType.Update:
					try
					{
						BeginCase("RowUpdate");
						Compare(drUpdate ,e.Row );
					}
					catch(Exception ex)	{exp = ex;}
					finally	{EndCase(exp); exp = null;}
					EventCounter++;
					break;
			}
		}
Example #2
0
 private void OleDbRowUpdatingHandler(object sender, OleDbRowUpdatingEventArgs ruevent)
 {
     RowUpdatingHandler(ruevent);
 }
Example #3
0
        void DataAdapter_RowUpdating(object sender, OleDbRowUpdatingEventArgs e)
        {
            string sInsertRegex = @"INSERT INTO ([ a-zA-Z0-9_]+) \((.+)\) VALUES \((.+)\)";
            string sUpdateRegex = @"UPDATE ([ a-zA-Z0-9_]+) SET (.+) WHERE (.+)";

            if (e.Command == null)
            {
            }
            else if (Regex.IsMatch(e.Command.CommandText, sInsertRegex))
            {
                Match rMatch = Regex.Match(e.Command.CommandText, sInsertRegex);
                e.Command.CommandText = e.Command.CommandText.Replace("INSERT INTO " + rMatch.Groups[1].Value, "INSERT INTO `" + rMatch.Groups[1].Value + "`");

                List<string> lFields = new List<string>(rMatch.Groups[2].Value.Split(','));
                foreach (string field in lFields.ToArray())
                {
                    lFields[lFields.IndexOf(field)] = "`" + field.TrimStart(' ') + "`";
                }
                e.Command.CommandText = e.Command.CommandText.Replace("(" + rMatch.Groups[2].Value + ")", "(" + string.Join(", ", lFields.ToArray()) + ")");
            }
            else if (Regex.IsMatch(e.Command.CommandText, sUpdateRegex))
            {
                Match rMatch = Regex.Match(e.Command.CommandText, sUpdateRegex);
                e.Command.CommandText = e.Command.CommandText.Replace("UPDATE " + rMatch.Groups[1].Value, "UPDATE `" + rMatch.Groups[1].Value + "`");

                List<string> lFields = new List<string>(rMatch.Groups[2].Value.Split(','));
                foreach (string field in lFields.ToArray()) lFields[lFields.IndexOf(field)] = field.TrimStart(' ');
                foreach (string field in lFields.ToArray())
                {
                    lFields[lFields.IndexOf(field)] = "`" + field.Substring(0, field.Length - 4) + "` = ?";
                }
                e.Command.CommandText = e.Command.CommandText.Replace("SET " + rMatch.Groups[2].Value + " WHERE", "SET " + string.Join(", ", lFields.ToArray()) + " WHERE");

                string sGroup3Replace = rMatch.Groups[3].Value;
                foreach (Match rFixup in Regex.Matches(sGroup3Replace, @"\(([ a-zA-Z0-9_]+) = ?"))
                {
                    sGroup3Replace = sGroup3Replace.Replace(
                        "(" + rFixup.Groups[1].Value + " = ?)",
                        "(`" + rFixup.Groups[1].Value + "` = ?)"
                    );
                }
                foreach (Match rFixup in Regex.Matches(sGroup3Replace, @"(AND|OR) ([ a-zA-Z0-9_]+) IS NULL"))
                {
                    sGroup3Replace = sGroup3Replace.Replace(
                        "" + rFixup.Groups[1].Value + " " + rFixup.Groups[2].Value + " IS NULL",
                        "" + rFixup.Groups[1].Value + " `" + rFixup.Groups[2].Value + "` IS NULL"
                    );
                }
                e.Command.CommandText = e.Command.CommandText.Replace(rMatch.Groups[3].Value, sGroup3Replace);
            }
        }
 private void OleDbRowUpdatingHandler(object sender, OleDbRowUpdatingEventArgs ruevent) {
     RowUpdatingHandler(ruevent);
 }
Example #5
0
		/// <summary>
		/// Handles the RowUpdating event
		/// </summary>
		/// <param name="obj">The object that published the event</param>
		/// <param name="e">The OleDbRowUpdatingEventArgs</param>
		protected void RowUpdating(object obj, OleDbRowUpdatingEventArgs e)
		{
			base.RowUpdating(obj, e);
		}
        /// <summary>
        /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// oledbrowupdatingeventhandler.BeginInvoke(sender, e, callback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginInvoke(this OleDbRowUpdatingEventHandler oledbrowupdatingeventhandler, Object sender, OleDbRowUpdatingEventArgs e, AsyncCallback callback)
        {
            if(oledbrowupdatingeventhandler == null) throw new ArgumentNullException("oledbrowupdatingeventhandler");

            return oledbrowupdatingeventhandler.BeginInvoke(sender, e, callback, null);
        }
Example #7
0
 public static void adapter_UpdateEvent(object sender, OleDbRowUpdatingEventArgs e)
 {
     //Console.WriteLine("adapter updates");
 }