if (deleteRMS) { const String strQuery = @"SELECT PS2.PARAMETER_SETTING_ID FROM TPARAMETER_SETTINGS(NOLOCK) PS1 INNER JOIN TPARAMS_IN_MM_LINKS(NOLOCK) PL ON PL.SRC_PARAMETER_SETTING_ID = PS1.PARAMETER_SETTING_ID INNER JOIN TPARAMETER_SETTINGS(NOLOCK) PS2 ON PS2.PARAMETER_SETTING_ID = PL.DST_PARAMETER_SETTING_ID WHERE PS1.PARAMETER_SETTING_ID = @PARAMETER_ID AND PS2.VALUE_TYPE_ID = 1"; SqlCommand commandDelete = null; try { commandDelete = new SqlCommand(strQuery, m_SQLConnection, m_Transaction); commandDelete.CommandTimeout = 0; SqlDataAdapter adapterDelete = new SqlDataAdapter(commandDelete); DataSet dataSetDelete = new DataSet(); adapterDelete.Fill(dataSetDelete); DataTable tableDelete = dataSetDelete.Tables[0]; foreach (DataRow rowDelete in tableDelete.Rows) { Guid parameterID = new Guid(rowDelete[0].ToString()); DeleteMeasurementData(Guid.Empty, Guid.Empty, parameterID); } } finally { if (commandDelete != null) commandDelete.Dispose(); } }