public string DescribeProblem(ISqlParameter parameter)
        {
            if (string.IsNullOrWhiteSpace(parameter.Value) || parameter.Value == AnyTableSqlParameter.DefaultValue)
            {
                return("No value defined");
            }


            if (AnyTableSqlParameter.HasProhibitedName(parameter))
            {
                return("Parameter name is a reserved name for the RDMP software");
            }

            return(null);
        }
        /// <summary>
        /// Updates the Sql code for the current state of the <see cref="Options"/>
        /// </summary>
        public void RegenerateSQL()
        {
            ProblemObjects = new Dictionary <ISqlParameter, Exception>();

            var parameterManager = Options.ParameterManager;

            Sections.Clear();

            try
            {
                IsBroken             = false;
                QueryEditor.ReadOnly = false;
                string sql             = "";
                var    finalParameters = parameterManager.GetFinalResolvedParametersList().ToArray();

                int currentLine = 0;

                foreach (ISqlParameter parameter in finalParameters)
                {
                    //if it's a user one
                    if (AnyTableSqlParameter.HasProhibitedName(parameter) && !ProblemObjects.ContainsKey(parameter))
                    {
                        ProblemObjects.Add(parameter, new Exception("Parameter name " + parameter.ParameterName + " is a reserved name for the RDMP software"));//advise them
                    }
                    try
                    {
                        parameter.Check(new ThrowImmediatelyCheckNotifier());
                    }
                    catch (SyntaxErrorException errorException)
                    {
                        if (!ProblemObjects.ContainsKey(parameter))
                        {
                            ProblemObjects.Add(parameter, errorException);
                        }
                    }


                    string toAdd = QueryBuilder.GetParameterDeclarationSQL(parameter);

                    int lineCount = GetLineCount(toAdd);

                    Sections.Add(new ParameterEditorScintillaSection(Options.Refactorer, currentLine, currentLine += (lineCount - 1), parameter,

                                                                     !Options.ShouldBeReadOnly(parameter),

                                                                     toAdd));

                    sql += toAdd;
                    currentLine++;
                }

                QueryEditor.Text = sql.TrimEnd();
            }
            catch (Exception ex)
            {
                QueryEditor.Text = ex.ToString();

                IsBroken = true;

                var exception = ex as QueryBuildingException;
                if (exception != null)
                {
                    foreach (ISqlParameter p in exception.ProblemObjects.OfType <ISqlParameter>())
                    {
                        if (!ProblemObjects.ContainsKey(p))//might have already added it up above
                        {
                            ProblemObjects.Add(p, ex);
                        }
                    }

                    ProblemObjectsFound();
                }
            }
            QueryEditor.ReadOnly = true;

            var highlighter = new ScintillaLineHighlightingHelper();

            highlighter.ClearAll(QueryEditor);

            foreach (ParameterEditorScintillaSection section in Sections)
            {
                if (!section.Editable)
                {
                    for (int i = section.LineStart; i <= section.LineEnd; i++)
                    {
                        highlighter.HighlightLine(QueryEditor, i, Color.LightGray);
                    }
                }
            }
        }