Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I'm reading this correctly, you've got a couple of problems here.</p> <p>Assuming you're connecting to a Microsoft SQL Server here (since you're using the SQLCommand), you're putting double quotes around the username and password variables, thereby denoting that you're comparing the column username with the column (whatever is in the variable). Let's say Username has "john" and password has "1234" in it. Your sql statement looks like this:</p> <pre><code>SELECT level FROM tblUsers WHERE username = "john" and password = "1234" </code></pre> <p>Double Quotes mean that whatever text is in there is the name of a column, so SQL is looking for columns called john and 1234. You should use single quotes / apostrophes.</p> <pre><code>SELECT level FROM tblUsers WHERE username = 'john' and password = '1234' </code></pre> <p>If you're using the username "username" and the password "password", you're actually just selecting level from the user table where the username column = the username column, and the password column = the password column. (:</p> <p>Anyway, besides all of that, pasting variables directly into your SQL query leaves your query open for SQL Injection, so it's better to use parameters.</p> <pre><code>SQLcommand.CommandText = "SELECT level FROM tblUsers WHERE username = @username AND password = @password" SQLcommand.Parameters.AddWithValue("@username",username) SQLcommand.Parameters.AddWithValue("@password",password) SQLreader = SQLcommand.ExecuteReader() </code></pre> <p>Give that a shot.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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