Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

MBS FileMaker Plugin Example Databases

Microsoft SQL Server Query

All examples are included with download of MBS FileMaker Plugin.

Microsoft SQL Server Query.fmp12

Overview
Tables 1
Relationships 0
Layouts 1
Scripts 1
Value Lists 0
Custom Functions 0
Custom Menus 33
File Options
Default custom menu set [Standard FileMaker Menus]
Default theme Minimalist
When opening file
Minimum allowed version 12.0
Login using Account Name; Account= Admin
Allow user to save password On
Require iOS passcode Off
Show Sign-in fields Off
Switch to layout Off
Hide all toolbars Off
Script triggers
OnFirstWindowOpen Off
OnLastWindowClose Off
OnWindowOpen Off
OnWindowClose Off
OnFileAVPlayerChange Off
OnWindowTransaction Off
Thumbnail Settings
Generate Thumbnails On; Temporary

 

Tables

Table Name
Statistics
Comments
Occurrences in Relationship Graph
SQLServer Query
7 fields defined, 3 records
SQLServer Query

Fields

Table Name: SQLServer Query - 7 Fields
Field Name Type Options Comments On Layouts In Relationships In Scripts In Value Lists
SQL Normal, Text Auto-Enter:
  • Allow editing
Validation:
  • Only during data entry
Storage:
  • Repetitions: 1
  • Indexing: None
  • Automatically create indexes as needed
  • Index Language: German
      Result Normal, Text Auto-Enter:
      • Allow editing
      Validation:
      • Only during data entry
      Storage:
      • Repetitions: 1
      • Indexing: None
      • Automatically create indexes as needed
      • Index Language: German
          Username Normal, Text Auto-Enter:
          • Allow editing
          Validation:
          • Only during data entry
          Storage:
          • Repetitions: 1
          • Indexing: None
          • Automatically create indexes as needed
          • Index Language: German
              Password Normal, Text Auto-Enter:
              • Allow editing
              Validation:
              • Only during data entry
              Storage:
              • Repetitions: 1
              • Indexing: None
              • Automatically create indexes as needed
              • Index Language: German
                  SQLConnectionString Normal, Text Auto-Enter:
                  • Allow editing
                  Validation:
                  • Only during data entry
                  Storage:
                  • Repetitions: 1
                  • Indexing: None
                  • Automatically create indexes as needed
                  • Index Language: German
                      Comment Normal, Text Auto-Enter:
                      • Allow editing
                      Validation:
                      • Only during data entry
                      Storage:
                      • Repetitions: 1
                      • Indexing: None
                      • Automatically create indexes as needed
                      • Index Language: German
                            ODBC Lib Path Normal, Text Auto-Enter:
                            • Allow editing
                            Validation:
                            • Only during data entry
                            Storage:
                            • Repetitions: 1
                            • Indexing: None
                            • Automatically create indexes as needed
                            • Index Language: German

                                Layout Objects: SQLServer Query

                                Regular Fields

                                Field Name: SQLServer Query::SQLConnectionString
                                Field Properties Coordinates Field Format Field Behavior Quick Find
                                • Top: 5 pt
                                • Left: 140 pt
                                • Bottom: 25 pt
                                • Right: 549 pt
                                • Anchoring: Left, Top
                                Field Format:
                                • Edit Box
                                Field Behavior:
                                • Allow field to be entered: In Find mode, In Browse mode
                                • Touch keyboard type: Default for Data Type
                                • Go to next field using: Tab key
                                Yes

                                Field Name: SQLServer Query::Username
                                Field Properties Coordinates Field Format Field Behavior Quick Find
                                • Top: 26 pt
                                • Left: 140 pt
                                • Bottom: 46 pt
                                • Right: 549 pt
                                • Anchoring: Left, Top
                                Field Format:
                                • Edit Box
                                Field Behavior:
                                • Allow field to be entered: In Find mode, In Browse mode
                                • Touch keyboard type: Default for Data Type
                                • Go to next field using: Tab key
                                Yes

                                Field Name: SQLServer Query::Password
                                Field Properties Coordinates Field Format Field Behavior Quick Find
                                • Top: 49 pt
                                • Left: 140 pt
                                • Bottom: 69 pt
                                • Right: 549 pt
                                • Anchoring: Left, Top
                                Field Format:
                                • Edit Box
                                Field Behavior:
                                • Allow field to be entered: In Find mode, In Browse mode
                                • Touch keyboard type: Default for Data Type
                                • Go to next field using: Tab key
                                Yes

                                Field Name: SQLServer Query::SQL
                                Field Properties Coordinates Field Format Field Behavior Quick Find
                                • Top: 130 pt
                                • Left: 140 pt
                                • Bottom: 149 pt
                                • Right: 393 pt
                                • Anchoring: Left, Top
                                Field Format:
                                • Edit Box
                                Field Behavior:
                                • Allow field to be entered: In Find mode, In Browse mode
                                • Touch keyboard type: Default for Data Type
                                • Go to next field using: Tab key
                                Yes

                                Field Name: SQLServer Query::Result
                                Field Properties Coordinates Field Format Field Behavior Quick Find
                                • Top: 157 pt
                                • Left: 140 pt
                                • Bottom: 417 pt
                                • Right: 557 pt
                                • Anchoring: Left, Top
                                Field Format:
                                • Edit Box
                                Field Behavior:
                                • Allow field to be entered: In Find mode, In Browse mode
                                • Touch keyboard type: Default for Data Type
                                • Go to next field using: Tab key
                                Yes

                                Field Name: SQLServer Query::ODBC Lib Path
                                Field Properties Coordinates Field Format Field Behavior Quick Find
                                • Top: 97 pt
                                • Left: 140 pt
                                • Bottom: 117 pt
                                • Right: 549 pt
                                • Anchoring: Left, Top
                                Field Format:
                                • Edit Box
                                Field Behavior:
                                • Allow field to be entered: In Find mode, In Browse mode
                                • Touch keyboard type: Default for Data Type
                                • Go to next field using: Tab key
                                Yes

                                Field Name: SQLServer Query::Comment
                                Field Properties Coordinates Field Format Field Behavior Quick Find
                                • Top: 73 pt
                                • Left: 140 pt
                                • Bottom: 93 pt
                                • Right: 549 pt
                                • Anchoring: Left, Top
                                Field Format:
                                • Edit Box
                                Field Behavior:
                                • Allow field to be entered: In Find mode, In Browse mode
                                • Touch keyboard type: Default for Data Type
                                • Go to next field using: Tab key
                                Yes

                                Buttons

                                Button Properties Coordinates Script/Script Step
                                  Type:
                                • Text: Run Query
                                  Additional Properties:
                                • Change to hand cursor over button
                                • Top: 85 pt
                                • Left: 580 pt
                                • Bottom: 117 pt
                                • Right: 723 pt
                                • Anchoring: Left, Top
                                Perform Script [ “RunQuery” ]

                                Scripts:


                                Script Hierarchy

                                RunQuery

                                Script Name RunQuery
                                Run script with full access privileges Off
                                Siri Shortcut Visible Off
                                Include In Menu Yes
                                Layouts that use this script
                                Scripts that use this script
                                  Script Definition
                                  Script Steps
                                  • Set Variable [ $r; Value:MBS("Trace") ]
                                  • Set Variable [ $Connection; Value:MBS("SQL.NewConnection") ]
                                  • If [ not IsEmpty ( SQLServer Query::ODBC Lib Path ) ]
                                  • #Tell plugin where ODBC library is. Leave empty for default
                                  • Set Variable [ $result; Value:MBS( "SQL.SetConnectionOption"; $Connection; "ODBC.LIBS"; SQLServer Query::ODBC Lib Path) ]
                                  • End If
                                  • If [ Get(SystemPlatform) = 1 ]
                                  • #Mac
                                  • #Tell plugin we want to use Microsoft SQL Server
                                  • Set Variable [ $result; Value:MBS("SQL.SetConnectionOption"; $Connection; "UseAPI"; "ODBC") ]
                                  • Set Variable [ $result; Value:MBS("SQL.SetClient"; $Connection; "ODBC") ]
                                  • Else [ ]
                                  • #Win
                                  • #Tell plugin we want to use Microsoft SQL Server
                                  • Set Variable [ $result; Value:MBS("SQL.SetClient"; $Connection; "SQLServer") ]
                                  • End If
                                  • #Connect to database in read/write/create mode. Creates new file if none exists.
                                  • Set Variable [ $result; Value:MBS("SQL.Connect"; $Connection; SQLServer Query::SQLConnectionString; SQLServer Query::Username; SQLServer Query::Password) ]
                                  • If [ $result ≠ "OK" ]
                                  • Show Custom Dialog [ Message: "Error: " & $result; Default Button: “OK”, Commit: “No”; Button 2: “Abbrechen”, Commit: “No” ]
                                  • Set Variable [ $result; Value:MBS("SQL.FreeConnection"; $Connection) ]
                                  • Halt Script
                                  • End If
                                  • #Create select and run it
                                  • Set Variable [ $Command; Value:MBS("SQL.NewCommand"; $Connection; SQLServer Query::SQL) ]
                                  • #Run it
                                  • Set Variable [ $result; Value:MBS("SQL.Execute"; $Command) ]
                                  • If [ $result ≠ "OK" ]
                                  • Set Field [ SQLServer Query::Result; $result ]
                                  • Show Custom Dialog [ Message: "Error: " & $result; Default Button: “OK”, Commit: “No”; Button 2: “Abbrechen”, Commit: “No” ]
                                  • Else [ ]
                                  • Set Variable [ $lines; Value:"" ]
                                  • Set Variable [ $fieldcount; Value:MBS("SQL.FieldCount"; $command) ]
                                  • Loop [ Flush: Always ]
                                  • Set Variable [ $result; Value:MBS("SQL.FetchNext"; $Command) ]
                                  • Exit Loop If [ $result ≠ 1 ]
                                  • Set Variable [ $line; Value:"" ]
                                  • Set Variable [ $i; Value:1 ]
                                  • Loop [ Flush: Always ]
                                  • Set Variable [ $v; Value:MBS("SQL.GetFieldAsText"; $command; $i) ]
                                  • Set Variable [ $n; Value:MBS("SQL.GetFieldName"; $command; $i) ]
                                  • Set Variable [ $line; Value:$line & $n & ": " & $v & ¶ ]
                                  • Set Variable [ $i; Value:$i+1 ]
                                  • Exit Loop If [ $i > $fieldCount ]
                                  • End Loop
                                  • Set Variable [ $lines; Value:$lines & ($line & ¶) ]
                                  • End Loop
                                  • Set Variable [ $lines; Value:$lines & ¶ ]
                                  • Set Field [ SQLServer Query::Result; $lines ]
                                  • End If
                                  • #Cleanup
                                  • Set Variable [ $result2; Value:MBS("SQL.FreeCommand"; $Command) ]
                                  • Set Variable [ $result2; Value:MBS("SQL.FreeConnection"; $Connection) ]
                                  Fields used in this script
                                  Scripts used in this script
                                    Layouts used in this script
                                      Tables used in this script
                                      Table occurrences used by this script
                                      Custom Functions used by this script
                                        Custom menu set used by this script

                                          Download example: Microsoft SQL Server Query

                                          Used functions: