private void mnuViewObjectScript_Click(object sender, System.EventArgs e)
        {
            if (lstResults.SelectedItems.Count == 0)
            {
                return;
            }

            ListViewItem item = lstResults.SelectedItems[0];

            SqlSync.ObjectScript.ObjectScriptHelper helper = new ObjectScriptHelper(this.connData);
            string script = string.Empty;
            string desc   = string.Empty;
            string message;
            string fullObjName = item.SubItems[0].Text;
            string name        = fullObjName;
            string schema;

            InfoHelper.ExtractNameAndSchema(name, out name, out schema);

            switch (item.SubItems[1].Text.Trim())
            {
            case "V":
                helper.ScriptDatabaseObject(SqlSync.Constants.DbObjectType.View, name, schema, ref script, ref desc, out message);
                break;

            case "P":
                helper.ScriptDatabaseObject(SqlSync.Constants.DbObjectType.StoredProcedure, name, schema, ref script, ref desc, out message);
                break;

            case "FN":
                helper.ScriptDatabaseObject(SqlSync.Constants.DbObjectType.UserDefinedFunction, name, schema, ref script, ref desc, out message);
                break;

            default:
                message = string.Empty;
                break;
            }

            if (script.Length > 0 || message.Length > 0)
            {
                ScriptDisplayForm frmDisplay;
                if (script.Length > 0)
                {
                    frmDisplay = new ScriptDisplayForm(script, this.connData.SQLServerName, item.SubItems[0].Text);
                }
                else
                {
                    frmDisplay = new ScriptDisplayForm(message, this.connData.SQLServerName, item.SubItems[0].Text);
                }

                frmDisplay.ShowDialog();
            }
        }
        private bool ScriptObject(string objectName, string schemaOwner, string type, string fullFileName, out string message)
        {
            bool   success        = false;
            string script         = string.Empty;
            string objectTypeDesc = string.Empty;


            success = helper.ScriptDatabaseObject(type, objectName, schemaOwner, ref script, ref objectTypeDesc, out message);
            if (success)
            {
                helper.SaveScriptToFile(script, objectName, objectTypeDesc, Path.GetFileName(fullFileName), fullFileName, true, true);
                return(true);
            }
            else
            {
                return(false);
            }
        }