private void SetLatLons(SqlParameterCollection spc, object MinLat, object MaxLat, object MinLon, object MaxLon)
 {
     if (!spc.Contains("@MinLat"))
     {
         spc.AddWithValue("@MinLat", MinLat);
     }
     if (!spc.Contains("@MaxLat"))
     {
         spc.AddWithValue("@MaxLat", MaxLat);
     }
     if (!spc.Contains("@MinLon"))
     {
         spc.AddWithValue("@MinLon", MinLon);
     }
     if (!spc.Contains("@MaxLon"))
     {
         spc.AddWithValue("@MaxLon", MaxLon);
     }
 }
Exemplo n.º 2
0
 public static void AddSqlParam(SqlParameterCollection pc,
                                Dictionary <string, object> vars)
 {
     foreach (var pair in vars)
     {
         if (pc.Contains(pair.Key))
         {
             pc[pair.Key].Value = pair.Value;
         }
         else
         {
             pc.AddWithValue(pair.Key, pair.Value);
         }
     }
 }
        /// <summary>
        /// Returns a copy of the given DbParameter that was added to the given collection.
        /// </summary>
        /// <param name="dbParameters">A DbParameter collection to add the parameter clone to</param>
        /// <param name="dbParam">A DbParameter to clone</param>
        /// <returns>The DbParameter clone</returns>
        public override DbParameter CopyParameterToCollection(DbParameterCollection dbParameters
                                                              , DbParameter dbParam)
        {
            SqlParameterCollection sqlParameters = (SqlParameterCollection)dbParameters;
            SqlParameter           sqlParam      = (SqlParameter)dbParam;

            if (sqlParameters.Contains(sqlParam.ParameterName))
            {
                throw new ExceptionEvent(enumExceptionEventCodes.DbParameterExistsInCollection
                                         , string.Format("Parameter {0} already belongs to this collection; use Set to change value."
                                                         , sqlParam.ParameterName));
            }

            sqlParameters.Add(CloneParameter(sqlParam));
            return(sqlParameters[sqlParam.ParameterName]);
        }
Exemplo n.º 4
0
        private static SqlParameterCollection ThreadSafeDetermineParms(string command, SqlParameterCollection parms, drGeneric_String_String globalInputs)
        {
            if (NonUpdatedProcedures.Instance.IsProcedureUpdated(command))
            {
                //******* 20121029 DHB Start code changes.
                //if (AppSettings.GlobalInputs == null)
                //{
                //    throw new ApplicationException("The procedure " + command + " has been flagged as being updated to accept GlobalInputs but the call to FetchDataTable did not include GlobalInputs. Please modify your call. Contact Wesley or Michael for further info.");
                //}
                //******* 20121029 DHB Stop code changes.
                if (!parms.Contains("GlobalInputs"))
                {
                    SqlParameter param = new SqlParameter("GlobalInputs", SqlDbType.Structured);
                    param.Value = globalInputs.ToDataTable();
                    parms.Add(param);
                }
                return(parms);
            }

            return(parms);
        }