Ich bin Daten aus der DB abrufen, wenn Benutzer Kontrollkästchen aktiviert. Werte im DB sind "JA" oder "NEIN". Sie funktionieren beide separat gut, aber wenn ich beide Kontrollkästchen anklicke, möchte ich alle Datensätze anzeigen, die beide Werte haben. Hier ist mein Code:Dynamic SQL - rufen Sie beide Checkbox-Werte aus DB
Using cmd As New OracleCommand()
Dim SQL As String = "Select * FROM MyTable "
Dim Bind_SQL As String = " Where "
Dim Activity As String
If ChkActiveYES.Checked = True Then
Activity = "YES"
SQL = String.Concat(SQL, Bind_SQL, " ACTIVE_PLAYER = :activity")
cmd.Parameters.Add(New OracleParameter("activity", Activity))
Bind_SQL = " and "
ElseIf ChkActiveNO.Checked = True Then
Activity = "NO"
SQL = String.Concat(SQL, Bind_SQL, " ACTIVE_PLAYER = :activity")
cmd.Parameters.Add(New OracleParameter("activity", Activity))
Bind_SQL = " and "
ElseIf ChkActiveYES.Checked = True And ChkActiveNO.Checked = True Then
Activity = "NO"
SQL = String.Concat(SQL, Bind_SQL, " ACTIVE_PLAYER = :activity")
cmd.Parameters.Add(New OracleParameter("activity", Activity))
Bind_SQL = " and "
Activity = "YES"
SQL = String.Concat(SQL, Bind_SQL, " ACTIVE_PLAYER = :activity")
cmd.Parameters.Add(New OracleParameter("activity", Activity))
Bind_SQL = " and "
End If
End using
Was fehlt mir hier?
Ich habe diesen Teil nicht einmal bemerkt. Das wird das unmittelbare Problem sein, aber sobald das gelöst ist, wird meine Antwort relevant werden. – jmcilhinney
Nicht so fließend mit "Oracle", aber er sagte, es funktioniert _individuell_, also dachte ich, das war das Problem. : D –
danke Crush, es funktioniert jetzt. – LuckyLuke82