Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion dotnet/src/dotnetframework/GxClasses/Data/GXDataADO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2719,7 +2719,12 @@ GxDataRecord getDbmsDataRecord(string id, string dbms)
switch (dbms)
{
case "sqlserver":
return new GxSqlServer();
GxSqlServer gxSqlServer = new GxSqlServer();
if (Config.GetValueOf("Connection-" + id + "-UseSmallDateTime", out cfgBuf) && cfgBuf == "1")
{
gxSqlServer.UseSmallDateTime();
}
return gxSqlServer;
case "mysql":
#if NETCORE
return new GxMySqlConnector(id);
Expand Down
25 changes: 15 additions & 10 deletions dotnet/src/dotnetframework/GxClasses/Data/GXDataCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1599,7 +1599,12 @@ public class GxSqlServer : GxDataRecord
private const string INTEGRATED_SECURITY_NO = "no";
#endif
private bool multipleDatareadersEnabled;
private DateTime SqlServer_NullDateTime= SQLSERVER_NULL_DATETIME;

internal void UseSmallDateTime()
{
SqlServer_NullDateTime = SQLSERVER_NULL_SMALLDATETIME;
}
public override int GetCommandTimeout()
{
return base.GetCommandTimeout();
Expand Down Expand Up @@ -2114,14 +2119,14 @@ public override DateTime Dbms2NetDate(IGxDbCommand cmd, IDataRecord DR, int i)
public override DateTime Dbms2NetDateTime( DateTime dt, Boolean precision)
{
//DBMS MinDate => Genexus null Date
if (dt.Equals(SQLSERVER_NULL_DATE))
if (dt.Equals(SqlServer_NullDateTime))
{
return DateTimeUtil.NullDate();
}

if (dt.Year==SQLSERVER_NULL_DATE.Year &&
dt.Month==SQLSERVER_NULL_DATE.Month &&
dt.Day==SQLSERVER_NULL_DATE.Day)
if (dt.Year== SqlServer_NullDateTime.Year &&
dt.Month== SqlServer_NullDateTime.Month &&
dt.Day== SqlServer_NullDateTime.Day)
{

return new DateTime(
Expand All @@ -2137,16 +2142,16 @@ public override Object Net2DbmsDateTime(IDbDataParameter parm, DateTime dt)
//Genexus null => save DBMS MinDate
if(dt.Equals(DateTimeUtil.NullDate()))
{
return SQLSERVER_NULL_DATE;
return SqlServer_NullDateTime;
}

//Date < DBMS MinDate => save DBMS MinDate keeping the Time component
if (dt.CompareTo(SQLSERVER_NULL_DATE)<0)
if (dt.CompareTo(SqlServer_NullDateTime) <0)
{
DateTime aux =
new DateTime(
SQLSERVER_NULL_DATE.Year,SQLSERVER_NULL_DATE.Month,
SQLSERVER_NULL_DATE.Day,dt.Hour,dt.Minute,dt.Second,dt.Millisecond);
SqlServer_NullDateTime.Year, SqlServer_NullDateTime.Month,
SqlServer_NullDateTime.Day,dt.Hour,dt.Minute,dt.Second,dt.Millisecond);

return aux;
}
Expand All @@ -2161,8 +2166,8 @@ public override string ConcatOp(int pos)
{
return ConcatOpValues[pos];
}

static DateTime SQLSERVER_NULL_DATE = new DateTime(1753,1,1) ;
static DateTime SQLSERVER_NULL_DATETIME = new DateTime(1753,1,1) ;
static DateTime SQLSERVER_NULL_SMALLDATETIME= new DateTime(1900, 1, 1);
}

public class GxDataReader: IDataReader
Expand Down