2016-04-21 16 views
2

Dies ist wahrscheinlich eine neue Frage, aber wie können Sie überprüfen, ob zwei Datentypen leer sind? Wenn eine Datentabelle Datensätze enthält und die andere nicht. Oder wenn sie beide Aufzeichnungen haben, tun sie etwas. Wenn keine Datensätze haben nichts tun.Prüfen, ob 2 Datenbanken vorhanden sind

If dt is nothing andalso dt.rows.count > 0 andalso dt2 is nothing andalso dt2.rows.count > 0 then 

    ' Process 

End if 
+0

Sie müssen sich über Ihre Terminologie genauer sein. Eine Datenbank ist keine Datentabelle. Wie auch immer, über welche Datenbank sprichst du hier? – Steve

+0

Sorry Auto Korrekt – Krev32

Antwort

3

Manchmal in einfacher Teile des Codes Aufspaltung könnte eine Lösung sein Komplex zu vermeiden, wenn die Bedingungen

Dim firstEmptyOrNull = dt is Nothing OrElse dt.Rows.Length = 0 
Dim secondEmptyOrNull = dt2 is Nothing OrElse dt2.Rows.Length = 0 

If firstEmptyOrNull And secondEmptyOrNull Then 
    ' Do nothing 
Else if Not firstEmptyOrNull And secondEmptyOrNull Then 
    ' Code if the first table is good but not the second one 
Else if firstEmptyOrNull And Not secondEmptyOrNull Then 
    ' Code if the second table is good but not the first one 
Else 
    ' Code for both tables good 
End If 
Verwandte Themen