2 Replies Latest reply on Apr 29, 2015 2:04 PM by philmodjunk

    How to get all databases in FileMaker pro using ODBC C#

    FanYang

      Title

      How to get all databases in FileMaker pro using ODBC C#

      Post

      I am working on an application to extract data from FileMaker pro using ODBC, I successfully get data from a specific table now

          try
          {
              conn = new OdbcConnection("DSN=FileMaker;Uid=Admin;Pwd=******");
              conn.Open();
              cmd = new OdbcCommand("SELECT * FROM SimpleProductTest");
              cmd.Connection = conn;
              dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
              if ((dr != null) && (dr.HasRows))
              {
                  while (dr.Read())
                  {
                          temp = dr.GetString(0);
                          Console.WriteLine(temp);
                  }
              }
      
              Console.WriteLine("Done.");
              Console.ReadLine();
          }

      Now I want to list all databases and tables in FileMaker Pro. Based on their document(http://www.filemaker.com/help/12/fmp/html/func_ref1.31.31.html), function DatabaseNames seems to be the right one.

      try
      {
          conn = new OdbcConnection("DSN=FileMaker;Uid=Admin;Pwd=******");
          conn.Open();
          cmd = new OdbcCommand("DatabaseNames");
          cmd.Connection = conn;
          dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
      
          if ((dr != null) && (dr.HasRows))
          {
              while (dr.Read())
              {
                  temp = dr.GetString(0);
                  Console.WriteLine(temp);
              }
          }
      
          Console.WriteLine("Done.");
          Console.ReadLine();
      }

      However, I get exceptions that query is not right, does anyone know how to list all databases and tables in FileMaker Pro? Also if there is function to list column names of a table?

      Thanks in advance

        • 1. Re: How to get all databases in FileMaker pro using ODBC C#
          FanYang

          No one knows the answer?

          • 2. Re: How to get all databases in FileMaker pro using ODBC C#
            philmodjunk

            Wow, not even an hour from when you first post and you are already wondering why there is no answer? Patience! You've asked a question that the average forum user won't understand. I can just barely understand the issue.

            The functions you have found, such as DatabaseNames are not SQL functions, they are functions evaluated within the NonSQL context of FileMaker calculations--either in script steps (not SQL), calculation fields and certain layout elements.

            You'd need to find an SQL equivalent in FileMaker SQL and I doubt such exists.

            If you have full access to the FileMaker Database, you might set up a calculation field that uses this function to list all currently open database files--what this function is defined to do, and then you could use SQL to query the value of this field, but note that this function lists Files, not tables so unless this database system consists of a number of one table files--which is possible, this function would be of no use to you even if you got it to work. (I've skipped over several issues with getting this to work as it does not appear to be the correct function anyway.)