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
Tables1
Relationships0
Layouts1
Scripts1
Value Lists0
Custom Functions0
Custom Menus33
File Options
Default custom menu set[Standard FileMaker Menus]
When opening file
Minimum allowed version12.0
Login usingAccount Name; Account= Admin
Allow user to save passwordOff
Require iOS passcodeOff
Switch to layoutOff
Hide all toolbarsOff
Script triggers
OnFirstWindowOpenOff
OnLastWindowCloseOff
OnWindowOpenOff
OnWindowCloseOff
OnFileAVPlayerChangeOff
Thumbnail Settings
Generate ThumbnailsOn; Temporary

 

Tables

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

Fields

Table Name: SQLServer Query - 6 Fields
Field NameTypeOptionsCommentsOn LayoutsIn RelationshipsIn ScriptsIn Value Lists
SQLNormal, TextAuto-Enter:
  • Allow editing
Validation:
  • Only during data entry
Storage:
  • Repetitions: 1
  • Indexing: None
  • Automatically create indexes as needed
  • Index Language: German
      ResultNormal, TextAuto-Enter:
      • Allow editing
      Validation:
      • Only during data entry
      Storage:
      • Repetitions: 1
      • Indexing: None
      • Automatically create indexes as needed
      • Index Language: German
          UsernameNormal, TextAuto-Enter:
          • Allow editing
          Validation:
          • Only during data entry
          Storage:
          • Repetitions: 1
          • Indexing: None
          • Automatically create indexes as needed
          • Index Language: German
              PasswordNormal, TextAuto-Enter:
              • Allow editing
              Validation:
              • Only during data entry
              Storage:
              • Repetitions: 1
              • Indexing: None
              • Automatically create indexes as needed
              • Index Language: German
                  SQLConnectionStringNormal, TextAuto-Enter:
                  • Allow editing
                  Validation:
                  • Only during data entry
                  Storage:
                  • Repetitions: 1
                  • Indexing: None
                  • Automatically create indexes as needed
                  • Index Language: German
                      CommentNormal, TextAuto-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::SQL
                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                          • Top: 96 pt
                          • Left: 138 pt
                          • Bottom: 110 pt
                          • Right: 553 pt
                          • Anchoring: Left, Top
                          Field Format:
                          • Edit Box
                          Field Behavior:
                          • Allow field to be entered: In Find mode, In Browse mode
                          • Touch keyboard type: System Default
                          • Go to next field using: Tab key
                          Yes

                          Field Name: SQLServer Query::Result
                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                          • Top: 114 pt
                          • Left: 138 pt
                          • Bottom: 320 pt
                          • Right: 553 pt
                          • Anchoring: Left, Top
                          Field Format:
                          • Edit Box
                          Field Behavior:
                          • Allow field to be entered: In Find mode, In Browse mode
                          • Touch keyboard type: System Default
                          • Go to next field using: Tab key
                          Yes

                          Field Name: SQLServer Query::Username
                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                          • Top: 18 pt
                          • Left: 138 pt
                          • Bottom: 32 pt
                          • Right: 391 pt
                          • Anchoring: Left, Top
                          Field Format:
                          • Edit Box
                          Field Behavior:
                          • Allow field to be entered: In Find mode, In Browse mode
                          • Touch keyboard type: System Default
                          • Go to next field using: Tab key
                          Yes

                          Field Name: SQLServer Query::Password
                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                          • Top: 36 pt
                          • Left: 138 pt
                          • Bottom: 50 pt
                          • Right: 391 pt
                          • Anchoring: Left, Top
                          Field Format:
                          • Edit Box
                          Field Behavior:
                          • Allow field to be entered: In Find mode, In Browse mode
                          • Touch keyboard type: System Default
                          • Go to next field using: Tab key
                          Yes

                          Field Name: SQLServer Query::SQLConnectionString
                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                          • Top: 54 pt
                          • Left: 138 pt
                          • Bottom: 68 pt
                          • Right: 391 pt
                          • Anchoring: Left, Top
                          Field Format:
                          • Edit Box
                          Field Behavior:
                          • Allow field to be entered: In Find mode, In Browse mode
                          • Touch keyboard type: System Default
                          • Go to next field using: Tab key
                          Yes

                          Field Name: SQLServer Query::Comment
                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                          • Top: 72 pt
                          • Left: 138 pt
                          • Bottom: 86 pt
                          • Right: 391 pt
                          • Anchoring: Left, Top
                          Field Format:
                          • Edit Box
                          Field Behavior:
                          • Allow field to be entered: In Find mode, In Browse mode
                          • Touch keyboard type: System Default
                          • Go to next field using: Tab key
                          Yes

                          Group Buttons

                          Button PropertiesCoordinatesScript/Script Step
                            Type:
                          • Text: Run Query
                            Additional Properties:
                          • Change to hand cursor over button
                          • Rectangular
                          • Top: 24 pt
                          • Left: 414 pt
                          • Bottom: 49 pt
                          • Right: 493 pt
                          • Anchoring: Left, Top
                          Perform Script [ “RunQuery” ]

                          Scripts:


                          Script Hierarchy

                          RunQuery

                          Script NameRunQuery
                          Run script with full access privilegesOff
                          Include In MenuYes
                          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 [ 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") ]
                            • #Tell plugin where SQLite library is
                            • Set Variable [ $result; Value:MBS( "SQL.SetConnectionOption"; $Connection; "ODBC.LIBS"; SQLServer Query::Comment) ]
                            • 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
                            • Set Variable [ $result; Value:MBS("SQL.FetchNext"; $Command) ]
                            • Exit Loop If [ $result ≠ 1 ]
                            • Set Variable [ $line; Value:"" ]
                            • Set Variable [ $i; Value:1 ]
                            • Loop
                            • 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: