AnsweredAssumed Answered

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

Question asked by FanYang on Apr 29, 2015
Latest reply on Apr 29, 2015 by philmodjunk

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

Outcomes