Note that there are some explanatory texts on larger screens.

plurals
  1. POC# use true/false from MySql database to either continue or show error
    text
    copied!<p>I need my app to get a true / false statement from database &amp; do something with it.</p> <p>In my Database i have a row called "ban" wich is <code>TinyInt(1)</code> for a true / false statement.</p> <p>If a user types his license name &amp; 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.</p> <p>Also the true/false statement of the inserted input will then be added as a ListBox item.</p> <p>Now i got that working, but actually i need my app to do something with true or false.</p> <p>So what i need is to get the true or false from the inserted input, &amp; then use it to say <em>"if false then open new window if true show an error inside a TextBox"</em></p> <p>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.</p> <p>I know it has something to do with Boolean, i just don't know how to work with it.</p> <p>Here's what i got so far: (not the complete code but i think this will do)</p> <p>Thanks!</p> <pre><code> 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(); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload