asp.net - How to avoid SQL injection -


i have tool points out sql injection issues , found 1 follows :

"select gb.btn,gup.cust_username,gup.email gbs_btn gb,gbs_user_btn gub,gbs_user_profile gup gb.btn=gub.btn , gub.cust_uid=gup.cust_uid , gb.et_id='" + straccountid + "' order create_date desc",ocin"

can please tell me how construct above query avoid sql injection?

option 1: use parameterized queries instead of contencating strings.

more info can found here: http://msdn.microsoft.com/en-us/library/ff648339.aspx

option 2: use parameterized stored procedures

option 3 escape strings using replace() should last resort. it's weak, , there ways around it.

string sql = "select * sometable somestringfield = '" + myvariable.replace("'", "''") + "'"; 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -