Click here to Skip to main content
15,890,438 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Help with a static class Pin
Stephen Holdorf20-May-15 5:21
Stephen Holdorf20-May-15 5:21 
GeneralRe: Help with a static class Pin
Sascha Lefèvre20-May-15 5:26
professionalSascha Lefèvre20-May-15 5:26 
GeneralRe: Help with a static class Pin
jkirkerx20-May-15 6:55
professionaljkirkerx20-May-15 6:55 
SuggestionRe: Help with a static class Pin
Richard Deeming20-May-15 7:08
mveRichard Deeming20-May-15 7:08 
GeneralRe: Help with a static class Pin
jkirkerx20-May-15 8:10
professionaljkirkerx20-May-15 8:10 
GeneralRe: Help with a static class Pin
Richard Deeming20-May-15 8:20
mveRichard Deeming20-May-15 8:20 
GeneralRe: Help with a static class Pin
jkirkerx20-May-15 9:15
professionaljkirkerx20-May-15 9:15 
GeneralRe: Help with a static class Pin
Stephen Holdorf21-May-15 2:50
Stephen Holdorf21-May-15 2:50 
The Veracode Scaner finally did not find this as an SQL injection error. The final fix:

namespace TAMIS.Business.Common
{
    public class MyParam
    {
        public SqlParameter SqlParam { get; set; }

        public string Name { get; set; }

        public object Value { get; set; }

        public int Type { get; set; }
    }
    /// <summary>
    /// Summary description for QueryContainer SGH
    /// </summary>
    public class QueryContainer
    {

        string _query;

        public List<myparam> parameterList = new List<myparam>();

        public QueryContainer(string query) { _query = query; }

        public SqlDbType AddParameterType(int type)
        {
            switch (type)
            {
                case 1:
                    return  (SqlDbType) Enum.Parse( typeof(SqlDbType) , "int" , true );
                case 2:
                    return (SqlDbType)Enum.Parse(typeof(SqlDbType), "NVarChar", true);
            }

            return SqlDbType.VarChar;
                
        }

        public string Query
        {
            get
            {
                return _query;
            }

            set { _query = value;  }
        }
    }

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.SqlParam = new SqlParameter("@account", Instance.AddParameterType(1));

            myParam.SqlParam.Value = account;
            
            Instance.parameterList.Add(myParam);
            
            return Convert.ToInt32(ExecuteScaler(Instance, 1));

protected Object ExecuteScaler(QueryContainer Instance, int i)
        {

            object returnValue = null;


            if (!_iserror)
            {
                if (_trace)
                {
                   // DoTrace("TAMIS.Data.Loader.ExecuteScalar", Instance.Query);
                }

                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)
                    {
                        command.Parameters.Add(p.SqlParam);
                    }

                    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;
                    }
                    finally
                    {

                        if ((!KeepAlive && _connection.State == ConnectionState.Open) || _iserror == true)
                        {
                            CloseConnection();
                        }

                    }
                }
            }
            else
            {
                returnValue = -1;
            }

            return returnValue;
        }

<pre>


modified 21-May-15 11:18am.

QuestionProblem With ASP.Net Webform using JQuery AJAX Pin
MadDashCoder14-May-15 23:09
MadDashCoder14-May-15 23:09 
AnswerRe: Problem With ASP.Net Webform using JQuery AJAX Pin
F-ES Sitecore14-May-15 23:33
professionalF-ES Sitecore14-May-15 23:33 
QuestionASP.NET web forms label set by jquery not updated in database Pin
spirospap13-May-15 15:27
spirospap13-May-15 15:27 
AnswerRe: ASP.NET web forms label set by jquery not updated in database Pin
F-ES Sitecore13-May-15 22:32
professionalF-ES Sitecore13-May-15 22:32 
QuestionASP.NET WebDav file upload Pin
candogu12-May-15 21:21
candogu12-May-15 21:21 
AnswerRe: ASP.NET WebDav file upload Pin
Richard Deeming13-May-15 1:28
mveRichard Deeming13-May-15 1:28 
QuestionBest method of delegating password resets Pin
sczii11-May-15 16:10
sczii11-May-15 16:10 
QuestionTextbox in Updatepanel doesnt submit text Pin
senglory7-May-15 21:46
senglory7-May-15 21:46 
AnswerRe: Textbox in Updatepanel doesnt submit text Pin
jkirkerx8-May-15 11:37
professionaljkirkerx8-May-15 11:37 
GeneralRe: Textbox in Updatepanel doesnt submit text Pin
senglory8-May-15 21:25
senglory8-May-15 21:25 
GeneralRe: Textbox in Updatepanel doesnt submit text Pin
senglory25-May-15 10:07
senglory25-May-15 10:07 
Questiondefault page redirect when go back home page. Pin
Ibrar Tariq7-May-15 21:35
Ibrar Tariq7-May-15 21:35 
QuestionRe: default page redirect when go back home page. Pin
ZurdoDev8-May-15 8:39
professionalZurdoDev8-May-15 8:39 
AnswerRe: default page redirect when go back home page. Pin
Ibrar Tariq8-May-15 15:44
Ibrar Tariq8-May-15 15:44 
AnswerRe: default page redirect when go back home page. Pin
Marjan Venema9-May-15 8:14
professionalMarjan Venema9-May-15 8:14 
GeneralRe: default page redirect when go back home page. Pin
ZurdoDev9-May-15 11:11
professionalZurdoDev9-May-15 11:11 
QuestionAdd Dynamic Field in SQL Server or XML Pin
ankitsoftdev7-May-15 7:05
ankitsoftdev7-May-15 7:05 

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.