From 4c98ee536331d535d988717e857f527a62060dff Mon Sep 17 00:00:00 2001
From: Claudia Beatriz Murialdo Garrone <c.murialdo@globant.com>
Date: Mon, 9 Sep 2024 16:33:14 -0300
Subject: [PATCH 1/2] Enhance Error log to include exception message on the
 same line.

---
 .../GxClasses/Data/GXDataADO.cs               | 34 +++++++++----------
 .../GxClasses/Data/GXDataCommon.cs            | 10 +++---
 .../GxClasses/Data/GXDataNTier.cs             | 12 +++----
 3 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/dotnet/src/dotnetframework/GxClasses/Data/GXDataADO.cs b/dotnet/src/dotnetframework/GxClasses/Data/GXDataADO.cs
index 7cfe94720..a98288731 100644
--- a/dotnet/src/dotnetframework/GxClasses/Data/GXDataADO.cs
+++ b/dotnet/src/dotnetframework/GxClasses/Data/GXDataADO.cs
@@ -87,7 +87,7 @@ protected GxConnectionManager()
 				}
 				catch(Exception e){
 
-					GXLogging.Error(log, "Error setting CONN_TIMEOUT ", e);
+					GXLogging.Error(log, "Error setting CONN_TIMEOUT ", e.Message, e);
 				}
 			}
 
@@ -209,7 +209,7 @@ public void RemoveAllConnections(int handle)
 			}
 			catch(Exception e)
 			{
-				GXLogging.Error(log, "RemoveAllConnections Error", e);
+				GXLogging.Error(log, "RemoveAllConnections Error", e.Message,e);
 				throw e;
 			}
 		}
@@ -526,7 +526,7 @@ public void Open()
 			}
 			catch (Exception ex)
 			{
-				GXLogging.Error(log, "GxConnection.Open Error ", ex);
+				GXLogging.Error(log, "GxConnection.Open Error ", ex.Message, ex);
 				lastErrorCode = 3;
 				lastErrorMsg = "Internal error: Function call failed (" + ex.Message + ")";
 				throw ex;
@@ -548,7 +548,7 @@ public void Open()
 					int status=0;
 					if (!m_dataRecord.ProcessError(e.DBMSErrorCode, e.ErrorInfo, GxErrorMask.GX_NOMASK, this, ref status, ref retry, 0))
 					{
-						GXLogging.Error(log, "GxConnection.Open Error ",e);
+						GXLogging.Error(log, "GxConnection.Open Error ", e.Message, e);
 						lastErrorCode = 3;
 						lastErrorMsg = "Internal error: Function call failed ("+  e.ErrorInfo + ")";
 						throw e;
@@ -700,7 +700,7 @@ public short FullConnect()
 			}
 			catch(Exception ex)
 			{
-				GXLogging.Error(log, "FullConnect Error " + databaseName, ex);
+				GXLogging.Error(log, "FullConnect Error " + databaseName, ex.Message, ex);
 				return 1;
 			}
 		}
@@ -1466,7 +1466,7 @@ public GxCommand( IGxDataRecord db, String statement, IGxDataStore ds, int ttl,
 				bool retry=false;
 				if (! dataRecord.ProcessError( e.DBMSErrorCode, e.ErrorInfo, errMask, con, ref status, ref retry, 0))
 				{
-					GXLogging.Error(log, "Return Error GxCommand ", e);
+					GXLogging.Error(log, "Return Error GxCommand ", e.Message, e);
 					throw (new GxADODataException(e.ErrorInfo, e));
 				}
 			}
@@ -1593,7 +1593,7 @@ public int ExecuteNonQuery()
                     }
                     catch { }
 				}
-				GXLogging.Error(log, e, "Return GxCommand.ExecuteNonQuery Error "); 
+				GXLogging.Error(log, "Return GxCommand.ExecuteNonQuery Error ", e.Message, e); 
 				try
 				{
 				con.MonitorExit();
@@ -1689,7 +1689,7 @@ private IDataReader ExecRpc()
 			}
 			catch(Exception e)
 			{
-				GXLogging.Error(log, e, "Return GxCommand.ExecRpc Error "); 
+				GXLogging.Error(log,"Return GxCommand.ExecRpc Error ", e.Message, e); 
 				throw (new GxADODataException(e));
 			}
 			finally
@@ -1728,7 +1728,7 @@ public string ExecuteDataSet()
 					}
 					catch(Exception e)
 					{
-						GXLogging.Error(log, e, "Return GxCommand.ExecuteDataSet Error "); 
+						GXLogging.Error(log, "Return GxCommand.ExecuteDataSet Error ", e.Message, e); 
 						throw (new GxADODataException(e));
 					}
 				}
@@ -1738,7 +1738,7 @@ public string ExecuteDataSet()
 					retryCount++;
 					if (! pe)
 					{
-						GXLogging.Error(log, e, "GxCommand.ExecuteDataSet Error ");
+						GXLogging.Error(log, "GxCommand.ExecuteDataSet Error ", e.Message, e);
 						throw;
 					}
 				}
@@ -1805,7 +1805,7 @@ public IDataReader ExecuteReader()
 			}
 			catch (Exception e)
 			{
-				GXLogging.Error(log, "Return GxCommand.ExecuteReader Error ", e);
+				GXLogging.Error(log, "Return GxCommand.ExecuteReader Error ", e.Message, e);
 				if (e.InnerException != null)
 				{
 					GXLogging.Error(log, "Inner Error", e.InnerException);
@@ -1839,7 +1839,7 @@ public void FetchData(out IDataReader dr)
 					retryCount++;
 					if (! pe)
 					{
-						GXLogging.Error(log, e, "GxCommand.FetchData Error ");
+						GXLogging.Error(log, "GxCommand.FetchData Error ", e.Message, e);
 						throw;
 					}
 				}
@@ -1866,7 +1866,7 @@ public void FetchDataRPC(out IDataReader dr)
 					retryCount++;
 					if (! pe)
 					{
-						GXLogging.Error(log, e, "GxCommand.FetchDataRPC Error ");
+						GXLogging.Error(log, "GxCommand.FetchDataRPC Error ", e.Message, e);
 						throw;
 					}
 				}
@@ -1923,7 +1923,7 @@ public int ExecuteBatchQuery()
             }
             catch (Exception e)
             {
-				GXLogging.Error(log, "Return GxCommand.ExecuteNonQuery Error ", e);
+				GXLogging.Error(log, "Return GxCommand.ExecuteNonQuery Error ", e.Message, e);
 				con.InternalConnection.RollbackSavePoint(Transaction, stmtId);
 				con.MonitorExit();
                 throw (new GxADODataException(e));
@@ -1988,7 +1988,7 @@ public void ExecuteBatch()
                     retryCount++;
                     if (!pe)
                     {
-                        GXLogging.Error(log, "GxCommand.ExecuteStmt Error ", e);
+                        GXLogging.Error(log, "GxCommand.ExecuteStmt Error ", e.Message, e);
 						throw;
                     }
                 }
@@ -2017,7 +2017,7 @@ private void execStmt()
                     retryCount++;
                     if (!pe)
                     {
-                        GXLogging.Error(log, "GxCommand.ExecuteStmt Error ", e);
+                        GXLogging.Error(log, "GxCommand.ExecuteStmt Error ", e.Message, e);
 						throw;
                     }
                 }
@@ -2599,7 +2599,7 @@ private void Initialize(IGxDataRecord db, string id, int hnd, IGxContext context
 						}
 						catch (Exception ex)
 						{
-							GXLogging.Error(log, "Error creating CustomDataRecord " + providerService.ClassName, ex);
+							GXLogging.Error(log, "Error creating CustomDataRecord " + providerService.ClassName, ex.Message, ex);
 						}
 					}
 				}
diff --git a/dotnet/src/dotnetframework/GxClasses/Data/GXDataCommon.cs b/dotnet/src/dotnetframework/GxClasses/Data/GXDataCommon.cs
index 1eb63d2f7..a7fa9c31d 100644
--- a/dotnet/src/dotnetframework/GxClasses/Data/GXDataCommon.cs
+++ b/dotnet/src/dotnetframework/GxClasses/Data/GXDataCommon.cs
@@ -829,7 +829,7 @@ public virtual IDbCommand GetCommand(IGxConnection con, string stmt, GxParameter
 								}
 								catch (Exception ex)
 								{
-									GXLogging.Error(log, "Set Binary parameter length in cached command error", ex);
+									GXLogging.Error(log, "Set Binary parameter length in cached command error", ex.Message, ex);
 								}
 							}
 						}
@@ -1963,7 +1963,7 @@ public override void GetValues(IDataReader reader, ref object[] values)
 			}
 			catch (Exception ex)
 			{
-				GXLogging.Error(log, "GetValues error", ex);
+				GXLogging.Error(log, "GetValues error", ex.Message, ex);
 			}
 		}
 		static internal decimal ReadSQLDecimal(SqlDataReader sqlReader, int idx) {
@@ -2261,7 +2261,7 @@ public bool Read()
 			}
 			catch (Exception ex)
 			{
-				GXLogging.Error(log, "ReadError", ex);
+				GXLogging.Error(log, "ReadError", ex.Message, ex);
 				throw (new GxADODataException(ex));
 			}
 		}
@@ -3162,7 +3162,7 @@ public void unprepare(int cursorId )
 			}
 			catch (Exception e)
 			{
-				GXLogging.Error(log, "GxCommand.unprepare Error ", e);
+				GXLogging.Error(log, "GxCommand.unprepare Error ", e.Message, e);
 			}
 		}
 		public void UnprepareClear()
@@ -3324,7 +3324,7 @@ public void LoadBlock()
             {
 				if (reader != null) reader.Close();
                 GXLogging.Error(log, "stmt:" + this.stmt);
-                GXLogging.Error(log, "LoadBlock error ", e);
+                GXLogging.Error(log, "LoadBlock error ", e.Message, e);
                 
                 Dispose();
                 hasnext = false;
diff --git a/dotnet/src/dotnetframework/GxClasses/Data/GXDataNTier.cs b/dotnet/src/dotnetframework/GxClasses/Data/GXDataNTier.cs
index fca522d83..c9e2675e8 100644
--- a/dotnet/src/dotnetframework/GxClasses/Data/GXDataNTier.cs
+++ b/dotnet/src/dotnetframework/GxClasses/Data/GXDataNTier.cs
@@ -476,7 +476,7 @@ private void execute(int cursor, Object[] parms, bool batch)
 					}
 					catch (Exception ex)
 					{
-						GXLogging.Error(log, "Execute error", ex);
+						GXLogging.Error(log, "Execute error", ex.Message, ex);
 						_ds.CloseConnections();
 						throw ex;
 					}
@@ -520,7 +520,7 @@ public void readNext(int cursor)
 				if (oCur != null)
 				{
 					bool pe = oCur.Command.ProcessException(e, ref retry, retryCount, "FETCH");
-					GXLogging.Error(log, "readNext Error", e);
+					GXLogging.Error(log, "readNext Error", e.Message, e);
 					if (!pe)
 					{
 						throw;
@@ -579,7 +579,7 @@ private void commitDataStore(IGxDataStore ds, String auditObjectName)
 				GxADODataException e = new GxADODataException(dbEx);
 				bool retry = false;
 				int retryCount = 0;
-				GXLogging.Error(log, "Commit Transaction Error", e);
+				GXLogging.Error(log, "Commit Transaction Error", e.Message, e);
 				bool pe = cmd.ProcessException(e, ref retry, retryCount, "FETCH");
 				if (!pe)
 				{
@@ -590,7 +590,7 @@ private void commitDataStore(IGxDataStore ds, String auditObjectName)
 					}
 					catch (Exception ex)
 					{
-						GXLogging.Error(log, "beginTransaction in commit transaction failed", ex);
+						GXLogging.Error(log, "beginTransaction in commit transaction failed",ex.Message, ex);
 						throw (new GxADODataException(e.ToString(), e));
 					}
 				}
@@ -612,7 +612,7 @@ private void rollbackDataStore(IGxDataStore ds, String auditObjectName)
 				bool retry = false;
 				int retryCount = 0;
 				bool pe = cmd.ProcessException(e, ref retry, retryCount, "FETCH");
-				GXLogging.Error(log, "Rollback Transaction Error", e);
+				GXLogging.Error(log, "Rollback Transaction Error", e.Message, e);
 				if (!pe)
 				{
 					try
@@ -622,7 +622,7 @@ private void rollbackDataStore(IGxDataStore ds, String auditObjectName)
 					}
 					catch (Exception ex)
 					{
-						GXLogging.Error(log, "beginTransaction in Rollback transaction failed", ex);
+						GXLogging.Error(log, "beginTransaction in Rollback transaction failed", ex.Message, ex);
 						throw (new GxADODataException(e.ToString(), e));
 					}
 				}

From f9a5d424e98f910272cc250e27dff0c3795a4710 Mon Sep 17 00:00:00 2001
From: Claudia Beatriz Murialdo Garrone <c.murialdo@globant.com>
Date: Tue, 1 Oct 2024 14:46:39 -0300
Subject: [PATCH 2/2] Improve log Error messages to include object name and
 stmt.

---
 .../GxClasses/Data/GXDataADO.cs               | 35 ++++++++++++-------
 .../GxClasses/Data/GXDataNTier.cs             | 21 ++++++-----
 .../GxClasses/Data/GXDataNTierADO.cs          | 12 ++++---
 .../GxClasses/Helpers/GXLogging.cs            | 12 +++++++
 4 files changed, 54 insertions(+), 26 deletions(-)

diff --git a/dotnet/src/dotnetframework/GxClasses/Data/GXDataADO.cs b/dotnet/src/dotnetframework/GxClasses/Data/GXDataADO.cs
index a98288731..0568d8292 100644
--- a/dotnet/src/dotnetframework/GxClasses/Data/GXDataADO.cs
+++ b/dotnet/src/dotnetframework/GxClasses/Data/GXDataADO.cs
@@ -1399,7 +1399,8 @@ public class GxCommand: IGxDbCommand
 		internal List<ParDef> ParmDefinition;
 		static readonly IGXLogger log = GXLoggerFactory.GetLogger<GxCommand>();
 		string stmt;
-        String stmtId;
+        string stmtId;
+		string objName;
         GxParameterCollection parameters;
 		ushort fetchSize=256;
 		int timeOut;
@@ -1484,6 +1485,7 @@ public GxCommand( IGxDataRecord db, String statement, short updatable,
 			IGxDataStore ds, string objName, string stmtId, int ttl, bool hasNested,bool isForFirst, GxErrorHandler errorHandler):this(db, statement,ds, ttl,hasNested, isForFirst, errorHandler)
 		{
             this.stmtId = stmtId;
+			this.objName = objName;
 		}
         public GxCommand(IGxDataRecord db, String statement, short updatable,
             IGxDataStore ds, string objName, string stmtId, int ttl, bool hasNested, bool isForFirst, GxErrorHandler errorHandler, int batchSize)
@@ -1593,7 +1595,7 @@ public int ExecuteNonQuery()
                     }
                     catch { }
 				}
-				GXLogging.Error(log, "Return GxCommand.ExecuteNonQuery Error ", e.Message, e); 
+				GXLogging.Error(log, () => "Return GxCommand.ExecuteNonQuery Error " + e.Message + StmtExceptionDetail, e); 
 				try
 				{
 				con.MonitorExit();
@@ -1689,7 +1691,7 @@ private IDataReader ExecRpc()
 			}
 			catch(Exception e)
 			{
-				GXLogging.Error(log,"Return GxCommand.ExecRpc Error ", e.Message, e); 
+				GXLogging.Error(log,() => "Return GxCommand.ExecRpc Error " + e.Message + StmtExceptionDetail, e); 
 				throw (new GxADODataException(e));
 			}
 			finally
@@ -1728,7 +1730,7 @@ public string ExecuteDataSet()
 					}
 					catch(Exception e)
 					{
-						GXLogging.Error(log, "Return GxCommand.ExecuteDataSet Error ", e.Message, e); 
+						GXLogging.Error(log, () => "Return GxCommand.ExecuteDataSet Error " + e.Message + StmtExceptionDetail, e); 
 						throw (new GxADODataException(e));
 					}
 				}
@@ -1738,7 +1740,7 @@ public string ExecuteDataSet()
 					retryCount++;
 					if (! pe)
 					{
-						GXLogging.Error(log, "GxCommand.ExecuteDataSet Error ", e.Message, e);
+						GXLogging.Error(log, () => "GxCommand.ExecuteDataSet Error " + e.Message + StmtExceptionDetail, e);
 						throw;
 					}
 				}
@@ -1805,7 +1807,7 @@ public IDataReader ExecuteReader()
 			}
 			catch (Exception e)
 			{
-				GXLogging.Error(log, "Return GxCommand.ExecuteReader Error ", e.Message, e);
+				GXLogging.Error(log, () => "Return GxCommand.ExecuteReader Error " + e.Message + StmtExceptionDetail, e);
 				if (e.InnerException != null)
 				{
 					GXLogging.Error(log, "Inner Error", e.InnerException);
@@ -1814,6 +1816,13 @@ public IDataReader ExecuteReader()
 			}
 
 		}
+		private string StmtExceptionDetail
+		{
+			get
+			{
+				return "\nObjectName:" + objName + "\nStmt:" + stmt;
+			}
+		}
 
 		public void FetchData(out IDataReader dr)
 		{
@@ -1839,7 +1848,7 @@ public void FetchData(out IDataReader dr)
 					retryCount++;
 					if (! pe)
 					{
-						GXLogging.Error(log, "GxCommand.FetchData Error ", e.Message, e);
+						GXLogging.Error(log, () => "GxCommand.FetchData Error " + e.Message + StmtExceptionDetail, e);
 						throw;
 					}
 				}
@@ -1866,7 +1875,7 @@ public void FetchDataRPC(out IDataReader dr)
 					retryCount++;
 					if (! pe)
 					{
-						GXLogging.Error(log, "GxCommand.FetchDataRPC Error ", e.Message, e);
+						GXLogging.Error(log, () => "GxCommand.FetchDataRPC Error " + e.Message + StmtExceptionDetail, e);
 						throw;
 					}
 				}
@@ -1923,7 +1932,7 @@ public int ExecuteBatchQuery()
             }
             catch (Exception e)
             {
-				GXLogging.Error(log, "Return GxCommand.ExecuteNonQuery Error ", e.Message, e);
+				GXLogging.Error(log, ()=>"Return GxCommand.ExecuteNonQuery Error " + e.Message + StmtExceptionDetail, e);
 				con.InternalConnection.RollbackSavePoint(Transaction, stmtId);
 				con.MonitorExit();
                 throw (new GxADODataException(e));
@@ -1986,9 +1995,9 @@ public void ExecuteBatch()
                 {
 					bool pe = ProcessException(e, ref retry, retryCount, "EXECUTE");
                     retryCount++;
-                    if (!pe)
-                    {
-                        GXLogging.Error(log, "GxCommand.ExecuteStmt Error ", e.Message, e);
+					if (!pe)
+					{
+						GXLogging.Error(log, () => "GxCommand.ExecuteStmt Error " + e.Message + StmtExceptionDetail, e);
 						throw;
                     }
                 }
@@ -2017,7 +2026,7 @@ private void execStmt()
                     retryCount++;
                     if (!pe)
                     {
-                        GXLogging.Error(log, "GxCommand.ExecuteStmt Error ", e.Message, e);
+						GXLogging.Error(log, ()=> "GxCommand.ExecuteStmt Error " + e.Message + StmtExceptionDetail, e);
 						throw;
                     }
                 }
diff --git a/dotnet/src/dotnetframework/GxClasses/Data/GXDataNTier.cs b/dotnet/src/dotnetframework/GxClasses/Data/GXDataNTier.cs
index c9e2675e8..fd9745c3e 100644
--- a/dotnet/src/dotnetframework/GxClasses/Data/GXDataNTier.cs
+++ b/dotnet/src/dotnetframework/GxClasses/Data/GXDataNTier.cs
@@ -52,7 +52,8 @@ public interface IRemoteDataStoreProvider
 
 	public interface ICursor
 	{
-		void createCursor( IGxDataStore ds, GxErrorHandler errorHandler );
+		void createCursor( IGxDataStore ds, GxErrorHandler errorHandler);
+		void createCursor(IGxDataStore ds, GxErrorHandler errorHandler, string objName);
 		void execute();
         short[] preExecute(int cursorNum, IDataStoreProviderBase connectionProvider, IGxDataStore ds);
         void readNext();
@@ -67,7 +68,7 @@ public interface ICursor
         void addRecord(Object[] parms);
         int BatchSize { get; set;}
         int RecordCount { get;}
-        void OnCommitEvent(object instance, string method);
+		void OnCommitEvent(object instance, string method);
         int readNextErrorRecord();
 		List<ParDef> DynamicParameters { get; }
     }
@@ -349,6 +350,7 @@ public class DataStoreProvider : IDataStoreProviderBase,IDataStoreProvider
 		IDictionary<int, Object[]> errorBuffers;
 		IGxDataStore _ds;
 		IDataStoreHelper _dataStoreHelper;
+		string _dataStoreHelperType;
 		object [] _dynConstraints;
 		GxErrorHandler _errorHandler;
         IGxContext _context;
@@ -359,16 +361,17 @@ public class DataStoreProvider : IDataStoreProviderBase,IDataStoreProvider
 
 		public DataStoreProvider( IGxContext context, IDataStoreHelper dataStoreHelper, Object[][] cursorParms)
 		{
-			GXLogging.Debug(log, "Start DataStoreProvider.Ctr, Parameters: handle '"+ context.handle + "', dataStoreHelper:" + dataStoreHelper.GetType());
+			_dataStoreHelperType = dataStoreHelper.GetType().ToString();
+			GXLogging.Debug(log, "Start DataStoreProvider.Ctr, Parameters: handle '"+ context.handle + "', dataStoreHelper:" + _dataStoreHelperType);
 			_dataStoreHelper = dataStoreHelper;
-            _context = context;
+			_context = context;
 			_ds = context.GetDataStore( dataStoreHelper.getDataStoreName());
 			if (_ds == null)
 			{
 				
                 _ds = new GxDataStore(new GxSqlServer(),dataStoreHelper.getDataStoreName(), context);
                 context.AddDataStore(_ds);
-                GXLogging.Error(log, dataStoreHelper.GetType() + " Datastore " + dataStoreHelper.getDataStoreName() + " not found in app config");
+                GXLogging.Error(log, _dataStoreHelperType + " Datastore " + dataStoreHelper.getDataStoreName() + " not found in app config");
 			}
 			_ds.Handle=context.handle; 
 			_cursor = dataStoreHelper.getCursors();
@@ -376,7 +379,7 @@ public DataStoreProvider( IGxContext context, IDataStoreHelper dataStoreHelper,
             errorBuffers = new Dictionary<int, Object[]>();
 			if (Preferences.Instrumented)
 			{
-				wmiDataStoreProvider = WMIDataStoreProviders.Instance().AddDataStoreProvider(dataStoreHelper.GetType().ToString());
+				wmiDataStoreProvider = WMIDataStoreProviders.Instance().AddDataStoreProvider(_dataStoreHelperType);
 			}
 			dataStoreRequestCount++;
 
@@ -420,8 +423,8 @@ private void execute(int cursor, Object[] parms, bool batch)
             }			
             if (!batch)
             {
-                oCur.createCursor(_ds, _errorHandler);
-            }
+                oCur.createCursor(_ds, _errorHandler, _dataStoreHelperType);
+			}
 			short[] parmHasValue = oCur.preExecute(cursor, this, _ds);
 			if (Preferences.Instrumented && wmiDataStoreProvider != null)
 			{
@@ -679,7 +682,7 @@ public void initializeBatch(int cursor, int batchSize, object instance, string m
             if (oCur.BatchSize == 0)
             {
                 oCur.BatchSize = batchSize;
-                oCur.createCursor(_ds, _errorHandler);
+                oCur.createCursor(_ds, _errorHandler, _dataStoreHelperType);
                 oCur.OnCommitEvent(instance, method);
             }
         }
diff --git a/dotnet/src/dotnetframework/GxClasses/Data/GXDataNTierADO.cs b/dotnet/src/dotnetframework/GxClasses/Data/GXDataNTierADO.cs
index bb448e76e..dff1664ea 100644
--- a/dotnet/src/dotnetframework/GxClasses/Data/GXDataNTierADO.cs
+++ b/dotnet/src/dotnetframework/GxClasses/Data/GXDataNTierADO.cs
@@ -849,8 +849,7 @@ internal GxCommand Command
 		{
 			get { return _gxDbCommand; }
 		}
-
-		public void createCursor(IGxDataStore ds, GxErrorHandler errorHandler)
+		public void createCursor(IGxDataStore ds, GxErrorHandler errorHandler, string objectName)
         {
 
             if (_state >= 2)
@@ -859,7 +858,7 @@ public void createCursor(IGxDataStore ds, GxErrorHandler errorHandler)
                 return;
             }
             _stmt = (_staticParameters == null)? _stmt : String.Format(_stmt, _staticParameters);
-            _gxDbCommand = new GxCommand(ds.Db, _stmt, _updatable, ds, "", _name, TTL, hasNested, isForFirst, errorHandler, _batchSize);
+            _gxDbCommand = new GxCommand(ds.Db, _stmt, _updatable, ds, objectName, _name, TTL, hasNested, isForFirst, errorHandler, _batchSize);
             _gxDbCommand.IsCursor = true;
             if (_blockSize > 0)
                 _gxDbCommand.FetchSize = Convert.ToUInt16(_blockSize);
@@ -871,7 +870,12 @@ public void createCursor(IGxDataStore ds, GxErrorHandler errorHandler)
             _gxDbCommand.ErrorMask = _errMask;
 
         }
-        protected virtual void bindParms(Object[] ptb)
+		public void createCursor(IGxDataStore ds, GxErrorHandler errorHandler)
+		{
+			createCursor(ds, errorHandler, string.Empty);
+		}
+
+		protected virtual void bindParms(Object[] ptb)
         {
             int pos = 1;
 			if (ptb != null)
diff --git a/dotnet/src/dotnetframework/GxClasses/Helpers/GXLogging.cs b/dotnet/src/dotnetframework/GxClasses/Helpers/GXLogging.cs
index c27480c41..fc89eb38a 100644
--- a/dotnet/src/dotnetframework/GxClasses/Helpers/GXLogging.cs
+++ b/dotnet/src/dotnetframework/GxClasses/Helpers/GXLogging.cs
@@ -600,6 +600,18 @@ internal static void ErrorSanitized(IGXLogger logger, string msg, Exception ex)
 				}
 			}
 		}
+		internal static void Error(IGXLogger logger, Func<string> buildMsg, Exception ex)
+		{
+			if (logger != null)
+			{
+				if (logger.IsErrorEnabled)
+				{
+					string msg = buildMsg();
+					logger.LogError(msg, ex);
+				}
+			}
+		}
+
 
 		internal static void Error(IGXLogger logger, string msg1, string msg2, Exception ex)
 		{