SQLBase 12.3, ADO.NET: How to assign null to a DateTime field?

Discussion forum about all things SqlBase or SqlTalk
isential
Germany
Posts: 19
Joined: 05 Jul 2017, 15:18
Location: Germany

SQLBase 12.3, ADO.NET: How to assign null to a DateTime field?

Post by isential » 23 Feb 2023, 19:45

I access the database with ADO.NET and C# (.NET 7). I need to assign "null" to a DateTime field, but I can't. I have tried the following options among others so far without success:

Code: Select all

cmd.Parameters.Add(":SYNCHRONISIERT", DbType.DateTime).Value = null;

cmd.Parameters.Add(":SYNCHRONISIERT", DbType.DateTime).Value = DBNull.Value;

cmd.Parameters.Add(":SYNCHRONISIERT", DbType.DateTime ).Value = (object)null ?? DBNull.Value

cmd.Parameters.Add(":SYNCHRONISIERT", DbType.DateTime).Value = DateTime.MinValue;

cmd.Parameters.Add(":SYNCHRONISIERT", DbType.DateTime).Value = DateTime.ParseExact(DateTime.MinValue.ToString(), "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture);

cmd.Parameters.Add(":SYNCHRONISIERT", DbType.DateTime).Value = DateTime.ParseExact("01/01/0001 00:00:00", "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture);

cmd.Parameters.Add(":SYNCHRONISIERT", DbType.DateTime).Value = DateTime.ParseExact("0001-01-01 00:00:00", "yyyy-dd-MM HH:mm:ss", CultureInfo.InvariantCulture);

cmd.Parameters.Add(":SYNCHRONISIERT", DbType.DateTime).Value = DateTime.Parse("0001-01-01 00:00:00");
How can I assign "null" to a DateTime?

Thank you in advance.

Return to “SqlBase General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 0 guests