Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Regular Expression Validator......

Regular Expression Validator......

Scheduled Pinned Locked Moved ASP.NET
databasesysadminregextutorial
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    greendragons
    wrote on last edited by
    #1

    Hello everyone, I got struck while finding a defense against sql injection.....plz explain how to use regular expression validators on server side so that user is unable to modify source code and inject code.....i found stored procedure a bit of complex so don't wanna use parameterised querries........

    A N A 3 Replies Last reply
    0
    • G greendragons

      Hello everyone, I got struck while finding a defense against sql injection.....plz explain how to use regular expression validators on server side so that user is unable to modify source code and inject code.....i found stored procedure a bit of complex so don't wanna use parameterised querries........

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      greendragons wrote:

      defense against sql injection

      you should read this article, SQL Injection Attacks and Some Tips on How to Prevent Them[^]

      Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

      1 Reply Last reply
      0
      • G greendragons

        Hello everyone, I got struck while finding a defense against sql injection.....plz explain how to use regular expression validators on server side so that user is unable to modify source code and inject code.....i found stored procedure a bit of complex so don't wanna use parameterised querries........

        N Offline
        N Offline
        N a v a n e e t h
        wrote on last edited by
        #3

        greendragons wrote:

        i found stored procedure a bit of complex so don't wanna use parameterised querries........

        Stored procedure and parameterized queries are not same. Parameterized queries are just normal queries with parameters. I don't think there is any complexity involved in using it and it is the obvious method to prevent SQL injection attacks.

        Navaneeth How to use google | Ask smart questions

        1 Reply Last reply
        0
        • G greendragons

          Hello everyone, I got struck while finding a defense against sql injection.....plz explain how to use regular expression validators on server side so that user is unable to modify source code and inject code.....i found stored procedure a bit of complex so don't wanna use parameterised querries........

          A Offline
          A Offline
          Abhishek Sur
          wrote on last edited by
          #4

          Hey.. Why do you need Regular Expression validators to prevent from SQL injection.... ?? I think it is good to have data validation in the client side... For Example : "\d+" will only take numeric values... You may use like "^(Insert|Update|Delete|Select)([A-Z][a-z]+)+" [It might be better if I take time] to ensure that the user dont enter DML statements in input. But why do you need to do this?? I think only a simple thing solves the entire problem. Say you have a TextBox called txtName in the page, you write :

          using(SqlCommand cmd = new SqlCommand("Update name = @pName where id='23'",con)) //assuming con = SqlConnection
          {
          SqlParameter param = new SqlParameter("@pName", SqlDbType.NVarchar);
          param.value = txtName.Text;// This line will automatically eliminates any SQL injection data.
          cmd.Parameters.add(param);
          cmd.ExecuteNonQuery();
          }

          Isnt it simple enough??? :cool:

          Abhishek Sur


          My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

          **Don't forget to click "Good Answer" if you like to.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups