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

  • SEARCH
  • Home
  • 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 6591047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:22:31+00:00 2026-05-25T17:22:31+00:00

Possible Duplicate: Classic ASP SQL Injection Protection So far, I’ve been very lucky not

  • 0

Possible Duplicate:
Classic ASP SQL Injection Protection

So far, I’ve been very lucky not to have my website attacked by SQL injection, and possibly many other methods too.

I would like to know how to convert my login query to use parameters, which apparently will stop this kind of attack occurring.

My query is actually quite complicated, so I will show a simple version in this post, so then I can study the converted version and then try and implement it to my real query later.

This is what I currently have (simplified), which is asking for trouble:

username = Trim(Request("username"))
password = Trim(Request("password"))

SQL = " SELECT clientID FROM clientAccounts
WHERE username = '"&username&"'AND password = '"&password&"'; "
Set rs = conn.Execute(SQL)

I would greatly appreciate if somebody could show me how this would look, using parameters, to protect it from injection.

Regards

  • 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-05-25T17:22:32+00:00Added an answer on May 25, 2026 at 5:22 pm

    From http://www.uberasp.net/getarticle.aspx?id=46 :

    SqlConnection objConnection = new SqlConnection(_ConnectionString);
    objConnection.Open();
    SqlCommand objCommand = new SqlCommand(
       "SELECT * FROM User WHERE Name = @Name AND Password = @Password",
       objConnection);
    objCommand.Parameters.Add("@Name", NameTextBox.Text);
    objCommand.Parameters.Add("@Password", PasswordTextBox.Text);
    SqlDataReader objReader = objCommand.ExecuteReader();
    if (objReader.Read())
    {
        ...
    

    For classic ASP, from http://blog.binarybooyah.com/blog/post/Classic-ASP-data-access-using-parameterized-SQL.aspx :

        With oSQLCommand
            .ActiveConnection = oSQLConn
            .CommandText = "SELECT * FROM whatever WHERE field1=@field1"
            'add input parameters
            .Parameters.Append .CreateParameter("field1", adInteger, adParamInput, , iTableIdValue)
        End With
        'run the stored procedure
        oRS.Open oSQLCommand
    

    Also, don’t write your own login code if it’s for anything important (i.e., you’re okay with the possibility of a complete stranger seeing everything on the server that you can). It takes a lot of time and testing to get it right, and one man alone (you) can’t reasonably hope to do it right the first time.

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

Sidebar

Related Questions

Possible Duplicate: Site has been hacked via SQL Injection Looks like one of my
Possible Duplicate: Multiple forms on ASP.NET page i have a doubt. can we place
Possible Duplicate: How to detect if JavaScript is disabled? I have a website which
Possible Duplicate: string1 >= string2 not implemented in Linq to SQL, any workarround? To
Possible Duplicate: Classic ASP on IIS7: refusing to send errors to browser on 500
Possible Duplicate: Classic ASP and ASP.NET Integration I got to work on one application
Possible Duplicate: Why not use tables for layout in HTML? Under what conditions should
Possible Duplicate: What Ruby IDE do you prefer? I've generally been doing stuff on
Possible Duplicate: How does the Google Did you mean? Algorithm work? Suppose you have
Possible Duplicate: Parsing text in C Say I have written to a text file

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.