Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

C# DateTime aus MsSQL 2005 führt zur Exception

Empfohlene Antworten

Veröffentlicht

Hallo,

ich habe eine Tabelle welche ein Attribut "geloescht_am" beinhaltet. Das ist nun ein DateTime und lässt null zu.


create table K_KATEGORIE (

   KATEGORIE_ID     bigint              not null,

   NAME                 nvarchar(30)    not null,

   GELOESCHT         bit                  not null    default 0,

   GELOESCHT_AM   datetime          not null

)

So wenn ich jetzt in C# ein Dataset fülle und dann die Rows durchlaufe, dann schmeißt er mir natürlich bei der Umwandlung in das DateTime bei "geloescht_am" eine Exeption, da DateTime nicht null sein darf. Ich komme leider nicht drauf wie ich die abfangen soll bzw. welchen defaultwert ich dem Attribut geben könnte ... :/
foreach (DS_Lebensakte.K_KATEGORIERow row in ds_Lebensakte.K_KATEGORIE.Rows)

{

 if ((row.GELOESCHT_AM).GetType() != typeof(DateTime))

{

   row.GELOESCHT_AM = DateTime.MinValue;

                            }



                            katListe.Add(new Kategorie(row.KATEGORIE_ID, row.NAME, row.GELOESCHT, row.GELOESCHT_AM));

                        }

Hat vielleicht hier jemand eine Idee?

Ja richtig, nur weiß ich nicht wie das default (am liebsten minvalue) aussehen soll :/


create table K_KATEGORIE (

   KATEGORIE_ID     bigint              not null,

   NAME                 nvarchar(30)    not null,

   GELOESCHT         bit                  not null    default 0,

   [B]GELOESCHT_AM   datetime          not null    default min_value;[/B]

)


oder wie?

Ja richtig, nur weiß ich nicht wie das default (am liebsten minvalue) aussehen soll :/


create table K_KATEGORIE (

   KATEGORIE_ID     bigint              not null,

   NAME                 nvarchar(30)    not null,

   GELOESCHT         bit                  not null    default 0,

   [B]GELOESCHT_AM   datetime          not null    default min_value;[/B]

)


oder wie?

Sorry..ich bin der Meinung, dass man sich das mit einer vorhandenen Dokumentation selber erarbeiten kann.

SQL Server 2005-Dokumentation

Danke schonmal für den Verweis auf die Online-Doku.

Damit hab ich die Lösung gefunden.

/closed

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.