I need my app to get a true / false statement from database & do something with it.
In my Database i have a row called "ban" wich is TinyInt(1)
for a true / false statement.
If a user types his license name & license number and clicks a button, my app wil compare the input data with specific rows in my database. So if ok = continue, if not ok, show error.
Also the true/false statement of the inserted input will then be added as a ListBox item.
Now i got that working, but actually i need my app to do something with true or false.
So what i need is to get the true or false from the inserted input, & then use it to say "if false then open new window if true show an error inside a TextBox"
Showing the errors is not a big deal, i got that working. The main thing here is using true or false to either continue or don't.
I know it has something to do with Boolean, i just don't know how to work with it.
Here's what i got so far: (not the complete code but i think this will do)
Thanks!
public partial class MainWindow : Window
{
string ConnectionString = Properties.Settings.Default.cloudpos_beheerCS;
public MainWindow()
{
InitializeComponent();
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
string Naamtxt = Naam.Text;
string Licentietxt = Licentie.Text;
MySqlConnection conn = new MySqlConnection(ConnectionString);
MySqlCommand cmdDatabase = conn.CreateCommand();
MySqlDataReader rdr;
cmdDatabase.CommandText = "SELECT * FROM cloudposgebruikers WHERE licentie = @licentie AND naam = @naam";
cmdDatabase.Parameters.AddWithValue("@naam", Naamtxt);
cmdDatabase.Parameters.AddWithValue("@licentie", Licentietxt);
try
{
conn.Open();
}
catch (Exception)
{
ErrorVerbinding.Content = "Er kan geen verbinding gemaakt worden met de database.";
return;
}
rdr = cmdDatabase.ExecuteReader();
int ollema = rdr.GetOrdinal("ban");
while (rdr.Read())
ListBox1.Items.Add(rdr.GetString(ollema));
conn.Close();
}
}