Exemplo n.º 1
0
        public static DataSet ExecuteSql(string connectionString, string commandText, params object[] vals)
        {
            SqlParameter[] commandParameters = null;

            if (vals != null)
            {
                commandParameters = new SqlParameter[vals.Length];

                for (int i = 0; i < vals.Length; i++)
                {
                    commandParameters.SetValue(new SqlParameter("@p" + (i + 1).ToString(), vals.GetValue(i)), i);
                }
            }

            return ExecuteSql(connectionString, commandText, commandParameters);
        }
Exemplo n.º 2
0
        private SqlParameter[] ConvertToSQLParam(IList<CustomParameter> param)
        {
            SqlParameter[] Sparameters = new SqlParameter[param.Count];
            SqlParameter subParam;
            for (int i = 0; i < param.Count; i++)
            {
                subParam = new SqlParameter(param[i].Name, param[i].Value);

                if (param[i].IsStructuredType == false && param[i].TypeName != null)
                {
                    if (param[i].TypeName == "SqlDbType.Image")
                    {
                        subParam.SqlDbType = SqlDbType.Image;
                    }
                }
                if (param[i].IsStructuredType)
                {
                    subParam.TypeName = param[i].TypeName;
                    subParam.SqlDbType = SqlDbType.Structured;
                }

                Sparameters.SetValue(subParam, i);
            }
            return Sparameters;
        }