Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7820885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:27:52+00:00 2026-06-02T07:27:52+00:00

We are trying to debug some legacy code. We have found that we are

  • 0

We are trying to debug some legacy code. We have found that we are able to log into the system by using the password “password” for all users. We can also log in with the username “username” and the password “password” as well as being able to log in with the username “username” and a password of one of the users in the system.

This makes us think that it may be a problem with the SQL query which may be matching the column “username” OR THE STRING “username” against the username field from the login form. (Same with the password).

However, we’re not VB.net people unfortunately and this behaviour seems to be the same no matter what we do. Here is the original code:

SQLcommand.CommandText = "SELECT level FROM tblUsers WHERE username = """ & username & """ AND password = """ & password & """"
SQLreader = SQLcommand.ExecuteReader()

(we’re not sure what all the """s are about)

So using what we know about programming and SQL we did this:

SQLcommand.CommandText = "SELECT level FROM tblUsers WHERE `username` = """ & username & """ AND `password` = """ & password & """"
SQLreader = SQLcommand.ExecuteReader()

Which had no effect, similarly:

SQLcommand.CommandText = "SELECT level FROM tblUsers WHERE tblUsers.username = """ & username & """ AND tblUsers.password = """ & password & """"
SQLreader = SQLcommand.ExecuteReader()

That had no effect either.

So the question is is this a problem with the SQL code? Or are we looking in the wrong place? I don’t think we are looking in the wrong place. Although we’re not VB.net people we’re still pretty proficient at programming. Also outputting (tracing) SQLreader(0) returns 1 for the query with “username” and “password” as the username and password which would mean that it is matching something.

Any help would be great. Is there something we are overlooking?

Thanks

(Disclaimer: this code isn’t used anywhere in a production environment. You can all relax now!)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T07:27:54+00:00Added an answer on June 2, 2026 at 7:27 am

    If I’m reading this correctly, you’ve got a couple of problems here.

    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:

    SELECT level FROM tblUsers WHERE username = "john" and password = "1234"
    

    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.

    SELECT level FROM tblUsers WHERE username = 'john' and password = '1234'
    

    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. (:

    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.

    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()
    

    Give that a shot.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to debug an android app that call native code to do some
I'm trying to debug some legacy Integration Services code, and really want some confirmation
I am trying to call some legacy C code using interop in C#. I
I'm trying to debug some code that uses COM, which I am a beginner
I am trying to debug some code using Response.Write , but when I run
I'm trying to debug a problem with some legacy code. While trying to understand
I'm trying to debug some native code I built using the android ndk-build script
I'm trying to debug some code that another developer wrote in jquery since page
I'm trying to debug some code in the .NET Framework. Unfortunately, many of the
I'm trying to use Firebug to debug some Javascript that entails blur and focus

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.