Click here to Skip to main content
15,887,585 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: Unable to stop SQL injection errors. Pin
Sascha Lefèvre29-May-15 12:55
professionalSascha Lefèvre29-May-15 12:55 
QuestionHow to get my "wp_nav_menu()" function working Pin
Truck5328-May-15 16:34
Truck5328-May-15 16:34 
QuestionHost Windows Class Library in PHP Pin
Jassim Rahma27-May-15 0:49
Jassim Rahma27-May-15 0:49 
QuestionMessage Removed Pin
22-May-15 4:28
Antonio Guedes22-May-15 4:28 
QuestionOpening an existing project in WordPress Pin
indian14321-May-15 21:21
indian14321-May-15 21:21 
AnswerRe: Opening an existing project in WordPress Pin
User 171649221-May-15 22:11
professionalUser 171649221-May-15 22:11 
QuestionImproper Neutralization of special elements used in an sql command Pin
Stephen Holdorf12-May-15 10:09
Stephen Holdorf12-May-15 10:09 
AnswerRe: Improper Neutralization of special elements used in an sql command Pin
Sascha Lefèvre12-May-15 10:33
professionalSascha Lefèvre12-May-15 10:33 
GeneralRe: Improper Neutralization of special elements used in an sql command Pin
Steve Holdorf12-May-15 12:38
Steve Holdorf12-May-15 12:38 
GeneralRe: Improper Neutralization of special elements used in an sql command Pin
Sascha Lefèvre12-May-15 12:54
professionalSascha Lefèvre12-May-15 12:54 
GeneralRe: Improper Neutralization of special elements used in an sql command Pin
Steve Holdorf12-May-15 13:01
Steve Holdorf12-May-15 13:01 
GeneralRe: Improper Neutralization of special elements used in an sql command Pin
Sascha Lefèvre12-May-15 13:17
professionalSascha Lefèvre12-May-15 13:17 
GeneralRe: Improper Neutralization of special elements used in an sql command Pin
Steve Holdorf12-May-15 14:14
Steve Holdorf12-May-15 14:14 
GeneralRe: Improper Neutralization of special elements used in an sql command Pin
Sascha Lefèvre12-May-15 14:54
professionalSascha Lefèvre12-May-15 14:54 
GeneralRe: Improper Neutralization of special elements used in an sql command Pin
Steve Holdorf12-May-15 15:34
Steve Holdorf12-May-15 15:34 
GeneralRe: Improper Neutralization of special elements used in an sql command Pin
Sascha Lefèvre12-May-15 15:44
professionalSascha Lefèvre12-May-15 15:44 
GeneralRe: Improper Neutralization of special elements used in an sql command Pin
Stephen Holdorf13-May-15 8:00
Stephen Holdorf13-May-15 8:00 
GeneralRe: Improper Neutralization of special elements used in an sql command Pin
Sascha Lefèvre13-May-15 9:53
professionalSascha Lefèvre13-May-15 9:53 
GeneralRe: Improper Neutralization of special elements used in an sql command Pin
PIEBALDconsult12-May-15 11:15
mvePIEBALDconsult12-May-15 11:15 
QuestionSQL Injection error. Pin
Stephen Holdorf12-May-15 9:43
Stephen Holdorf12-May-15 9:43 
AnswerRe: SQL Injection error. Pin
Sascha Lefèvre12-May-15 10:22
professionalSascha Lefèvre12-May-15 10:22 
AnswerRe: SQL Injection error. Pin
Richard Deeming13-May-15 1:38
mveRichard Deeming13-May-15 1:38 
GeneralRe: SQL Injection error. Pin
Stephen Holdorf20-May-15 3:24
Stephen Holdorf20-May-15 3:24 
I know there are a lot of posts but I finally understand and did what I was told to do. I broke the query up with parameters and I am still getting the security error. My code is below the with the parameters removed from the hard coded string, the calling code, and the implementing code:

The 3 classes with the SQL w/ with the parameters broken out, the calling code, and the implementing code:


Class with the parameters broken out:



public class MyParam
    {
        public string name { get; set; }
        public string value { get; set; }
    }
    /// 
    /// Summary description for QueryContainer SGH
    /// 
    public class QueryContainer
    {
 
        string _query;
 
        public List parameterList = new List(); 
 
        public QueryContainer(string query) { _query = query; }
 
        public string Query
        {
            get
            {
                return _query;
            }
 
            set { _query = value;  }
        }
    }<pre>
 
The calling code:
 

<pre>
        public int GetAccountSortByAccountCode(int account)
        {
            QueryContainer Instance = new QueryContainer("SELECT ac_sort_order FROM lkup_account_codes where ac_code = <a href="http://www.codeproject.com/Members/account">@account</a>");
 
            MyParam myParam = new MyParam();
 
            myParam.name = "@account";
            myParam.value = account.ToString();
 
            Instance.parameterList.Add(myParam);
 
            return Convert.ToInt32(ExecuteScaler(Instance, 1));
        } 
<pre>
 
The implementing code:
 
<pre>
                if (_connection == null || _connection.State == ConnectionState.Closed)
                {
                    OpenConnection();
                }
 
                DbCommand command = _provider.CreateCommand();
                command.Connection = _connection;
                {
                    command.CommandText = Instance.Query;
                    command.CommandType = CommandType.Text;
 
                    foreach (var p in Instance.parameterList)
                    {
                        SqlParameter param = new SqlParameter(p.name, p.value);
                        command.Parameters.Add(param);
                    }
 
                    if (_useTransaction) { command.Transaction = _transaction; }
 
                    try
                    {
                        returnValue = command.ExecuteScalar();
                    }
                    catch (Exception ex)
                    {
                        if (ex is EntryPointNotFoundException)
                            throw ex;
                        //if (_useTransaction == true)
                        //_transaction.Rollback();
                        RollBack();
 
                        LogBLL bll = new LogBLL();
                        bll.WriteErrorLog(ex);
 
                        _iserror = true;
                    }
<pre>

QuestionAuthorize.net PayPal Option Pin
jkirkerx11-May-15 12:24
professionaljkirkerx11-May-15 12:24 
QuestionDashboard samples reference Pin
sma123#11-May-15 5:46
sma123#11-May-15 5:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.