public static void ValidateBindVariables(this System.Data.Common.DbCommand command) { if (command.CommandType != System.Data.CommandType.Text) { throw new Exception("Cannot call ValidateBindVariables if not parameterized query"); } List <string> bindVariables = DatabaseUtilities.ExtractBindVariables(command.CommandText); System.Data.Common.DbParameterCollection dbParameters = command.Parameters; foreach (string variable in bindVariables) { bool bound = false; foreach (System.Data.Common.DbParameter parameter in dbParameters) { if (parameter.ParameterName.Equals(variable, System.StringComparison.CurrentCultureIgnoreCase)) { bound = true; break; } } if (!bound) { throw new Exception(string.Format("{0} is not bound", variable)); } } }
protected override void AddResults(System.Data.Common.DbParameterCollection dbParameters, ScanResult result) { dbParameters[0].Value = result.ScanSet.PrimaryScanNumber; dbParameters[1].Value = result.ScanTime; dbParameters[2].Value = result.SpectrumType; dbParameters[3].Value = result.BasePeak.Height; dbParameters[4].Value = result.BasePeak.XValue; dbParameters[5].Value = result.TICValue; dbParameters[6].Value = result.NumPeaks; dbParameters[7].Value = result.NumIsotopicProfiles; }
public bool PropagateStatementAsDbCommandEx(System.Data.Common.DbParameterCollection parameters, int referencecount) { if (secondarydbs == null) { return(true); } foreach (Iddl slave in secondarydbs) { slave.ManifoldCurrentStatementAsDbCommandEx(parameters); } return(true); }
public string genSQLCmd(string InSqlCmd, System.Data.Common.DbParameterCollection p) { if (p.Count > 0 && InSqlCmd != null) { foreach (System.Data.Common.DbParameter x in p) { if (x != null && x.ParameterName != null) { InSqlCmd = InSqlCmd.Replace(":" + x.ParameterName, "'" + (x.Value == null ? "" : x.Value.ToString()) + "'"); } } } return(InSqlCmd == null ? "" : InSqlCmd); }
///<summary> ///Convert SQL command with Parameters to STRSQL ///Wywolanie ///</summary> ///<example> /// crycore.sqldebug.CommandParametersToSQL(e.Command.CommandText , e.Command.Parameters, e.Command.CommandType.ToString()); ///</example> public static string CommandParametersToSQLSimple(string selectCommand, System.Data.Common.DbParameterCollection parameters, string commandType) { //Convert parameters to STRSQL if (parameters != null) { int count = parameters.Count; for (int i = 0; i < count; i++) { selectCommand = selectCommand.Replace(parameters[i].ParameterName, SqlString(parameters[i])); } } return(selectCommand); //konie iteracja wsrod parametrow }
protected override void AddResults(System.Data.Common.DbParameterCollection dbParameters, IsosResult result) { dbParameters[0].Value = result.MSFeatureID; dbParameters[1].Value = ((UIMFIsosResult)result).ScanSet.PrimaryScanNumber; dbParameters[2].Value = ((UIMFIsosResult)result).IMSScanSet.PrimaryScanNumber; dbParameters[3].Value = result.IsotopicProfile.ChargeState; dbParameters[4].Value = result.IsotopicProfile.GetAbundance(); dbParameters[5].Value = result.IsotopicProfile.GetMZ(); dbParameters[6].Value = result.IsotopicProfile.GetScore(); dbParameters[7].Value = result.IsotopicProfile.AverageMass; dbParameters[8].Value = result.IsotopicProfile.MonoIsotopicMass; dbParameters[9].Value = result.IsotopicProfile.MostAbundantIsotopeMass; dbParameters[10].Value = result.IsotopicProfile.GetFWHM(); dbParameters[11].Value = result.IsotopicProfile.GetSignalToNoise(); dbParameters[12].Value = result.IsotopicProfile.GetMonoAbundance(); dbParameters[13].Value = result.IsotopicProfile.GetMonoPlusTwoAbundance(); dbParameters[14].Value = ((UIMFIsosResult)result).DriftTime; dbParameters[15].Value = result.IsotopicProfile.OriginalIntensity; dbParameters[16].Value = result.IsotopicProfile.IsSaturated ? 1 : 0; dbParameters[17].Value = ProcessingTasks.ResultValidators.ResultValidationUtils.GetStringFlagCode(result.Flags); dbParameters[18].Value = result.InterferenceScore; }
/// <summary> /// DbParameterCollectionHelper /// </summary> /// <param name="Parameters"></param> public DbParameterCollectionHelper(System.Data.Common.DbParameterCollection Parameters) { _Parameters = Parameters; }
private static string BuildSqlWithSqlParameter(string sql, System.Data.Common.DbParameterCollection paras) { System.Data.Common.DbParameter[] arrParas = new System.Data.Common.DbParameter[paras.Count]; for (int i = 0; i < paras.Count; i++) { arrParas[i] = paras[i]; } Array.Sort(arrParas, new DbParameterForSort()); object[] objParas = new object[arrParas.Length]; for (int i = 0; i < arrParas.Length; i++) { sql = sql.Replace(arrParas[i].ParameterName, "{" + i.ToString() + "}"); switch (arrParas[i].DbType) { case System.Data.DbType.AnsiString: case System.Data.DbType.AnsiStringFixedLength: case System.Data.DbType.String: case System.Data.DbType.StringFixedLength: case System.Data.DbType.Xml: objParas[i] = arrParas[i].Value as string; break; case System.Data.DbType.Boolean: if (arrParas[i].Value == null) { objParas[i] = null; } else { objParas[i] = arrParas[i].Value.ToString(); } break; case System.Data.DbType.Date: if (arrParas[i].Value == null) { objParas[i] = null; } else { objParas[i] = ((DateTime)arrParas[i].Value).ToString("yyyy-MM-dd"); } break; case System.Data.DbType.DateTime: case System.Data.DbType.DateTime2: if (arrParas[i].Value == null) { objParas[i] = null; } else { objParas[i] = ((DateTime)arrParas[i].Value).ToString("yyyy-MM-dd HH:mm:ss"); } break; case System.Data.DbType.Time: if (arrParas[i].Value == null) { objParas[i] = null; } else { objParas[i] = ((DateTime)arrParas[i].Value).ToString("HH:mm:ss"); } break; case System.Data.DbType.Byte: case System.Data.DbType.UInt16: case System.Data.DbType.UInt32: case System.Data.DbType.UInt64: if (arrParas[i].Value == null) { objParas[i] = null; } else { objParas[i] = ulong.Parse(arrParas[i].Value.ToString()); } break; case System.Data.DbType.Decimal: case System.Data.DbType.Double: case System.Data.DbType.Single: if (arrParas[i].Value == null) { objParas[i] = null; } else { objParas[i] = double.Parse(arrParas[i].Value.ToString()); } break; case System.Data.DbType.Int16: case System.Data.DbType.Int32: case System.Data.DbType.Int64: case System.Data.DbType.SByte: if (arrParas[i].Value == null) { objParas[i] = null; } else { objParas[i] = long.Parse(arrParas[i].Value.ToString()); } break; default: throw new System.Data.DataException(string.Format("Invalid parameter DataType: {0}", arrParas[i].DbType)); } } return(BuildSql(sql, objParas)); }
/// <summary> /// DbParameterCollectionHelper /// </summary> /// <param name="Parameters"></param> public DbParameterCollectionHelper(System.Data.Common.DbParameterCollection Parameters) { _Parameters = Parameters; }