DataConnector | ComponentOne
ADO.NET provider for Kintone / Schema Details
In This Topic
    Schema Details
    In This Topic

    The ADO.NET provider for Kintone supports schema discovery using ADO.NET classes or SQL statements to the system tables. This is done through the GetSchema method of the C1KintoneConnection class, which optionally specifies the schema name and restriction values.

    In the following code example, the GetSchema method is called to return the tables in the database. In the second call, the method returns the columns in a specific data table.

    C#
    Copy Code
    static void SchemaDetails()
    {
        const string Username = "*******";
        const string Password = "*********";
        const string Url = "https://xg0w2.kintone.com";
    
        string kintoneConnection = string.Format("Username={0};Password={1};Url={2}", Username, Password, Url);
    
        using (C1KintoneConnection connection = new C1KintoneConnection(kintoneConnection))
        {
            connection.Open();
            //Get list of tables
            DataTable databaseTables = connection.GetSchema("Tables");
            Console.WriteLine("List of Tables in database:");
            foreach (DataRow row in databaseTables.Rows)
            {
                //Display Tablename
                Console.WriteLine(row["TableName"]);
            }
            //Get column names in a table
            DataTable datatableColumns = connection.GetSchema("Columns", new string[] { "Products" });
            Console.WriteLine("\n Products Table columns:");
            foreach (DataRow column in datatableColumns.Rows)
            {
                //Display column properties                  
                Console.Write(column["ColumnName"]);
                Console.Write("\t" + column["DataType"]);                    
            }
        }
    }

    Alternatively to the GetSchema method, you can also use the GetSchemaTable method of the C1DataReader class which returns a DataTable with the definition of the column metadata.