Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Ihebc_sfx
New Member

Custom connector for SQL Server Database

Hello

I have this sample of  custom connector

But when i test it ihave this error message 

7 arguments ont été passés à une fonction qui en attendait entre 1 et 2.

But i don't know where is my error exactly

 

[Version = "1.0.0"]

section DirectSQL;

 

// Définissez d'abord la fonction GetOdbcDataSource

GetOdbcDataSource = (server as text, database as text) as table =>

    let

        ConnectionString = [

            Driver = "SQL Server Native Client 11.0",

            Server = server,

            Database = database

        ],

        Credential = Extension.CurrentCredential(),

        CredentialConnectionString =

            if (Credential[AuthenticationKind]?) = "UsernamePassword" then

                [UID = Credential[Username], PWD = Credential[Password]]

            else if (Credential[AuthenticationKind]?) = "Windows" then

                [Trusted_Connection = "Yes"]

            else

                error "Unknown authentication kind",

        OdbcOptions = [

            CredentialConnectionString = CredentialConnectionString,

            ClientConnectionPooling = true,

            HierarchicalNavigation = true,

            SqlCapabilities = [

                SupportsTop = true,

                Sql92Conformance = 8,

                GroupByCapabilities = 4,

                FractionalSecondsScale = 3

            ],

            SoftNumbers = true,

            HideNativeQuery = true,

            SQLGetInfo = [

                SQL_SQL92_PREDICATES = 0x0000FFFF,

                SQL_AGGREGATE_FUNCTIONS = 0xFF

            ]

        ],

        OdbcDataSource = Odbc.DataSource(ConnectionString, OdbcOptions)

    in

        OdbcDataSource{[Name = database]}[Data];

 

// Ensuite, définissez les fonctions GetTable, GetArticleTable et GetClientTable

GetTable = (server as text, database as text, schemaName as text, tableName as text, columnNames as list) =>

    let

        Source = GetOdbcDataSource(server, database),

        dbo_Schema = Source{[Name = schemaName, Kind = "Schema"]}[Data],

        table = dbo_Schema{[Name = tableName, Kind = "Table"]}[Data],

        filteredTable = Table.SelectColumns(table, columnNames)

    in

        filteredTable;

 

GetArticleTable = (server as text, database as text) =>

    GetTable(server, database, "dbo", "F_Article", {"AR_Ref", "AR_Design"});

 

GetClientTable = (server as text, database as text) =>

    GetTable(server, database, "dbo", "F_Comptet", {"CT_Num", "CT_Intitule"});

 

// Définissez votre source de données DirectSQL.Database

[DataSource.Kind = "DirectSQL", Publish = "DirectSQL.UI"]

shared DirectSQL.Database = (server as text, database as text) as table =>

let

    // Appel à GetArticleTable avec les arguments server et database

    articleTable = GetArticleTable(server, database),

 

    // Appel à GetClientTable avec les arguments server et database

    clientTable = GetClientTable(server, database),

 

    // Créez la table de navigation en utilisant les résultats des appels précédents

    navTable = #table(

        {"Name", "Data", "ItemKind", "ItemName", "IsLeaf"}, {

            { "Client", clientTable, "Table", "Table", true },

            { "Article", articleTable, "Table", "Table", true }

        }

    )

in

    navTable;

 

// Définition de votre connecteur DirectSQL

DirectSQL = [

    TestConnection = (dataSourcePath) =>

        let

            json = Json.Document(dataSourcePath), server = json[server], database = json[database]

        in

            {"DirectSQL.Database", server, database},

    Authentication = [

        Windows = [],

        UsernamePassword = []

    ],

    Label = "Direct Query for SQL APBS",

    // This sample doesn't enable the use of SSL.

    SupportsEncryption = false

];

 

// Définition de l'exportation UI de votre connecteur

DirectSQL.UI = [

    // enables direct query

    SupportsDirectQuery = false,

    Beta = true,

    Category = "Database",

    ButtonText = {"APBS Sage 100c", "APBS Sage 100c Connector"},

    SourceImage = DirectSQL.Icons,

    SourceTypeImage = DirectSQL.Icons

];

 

// Définition des icônes pour votre connecteur

DirectSQL.Icons = [

    Icon16 = {

        Extension.Contents("DirectQueryForSQL16.png"),

        Extension.Contents("DirectQueryForSQL20.png"),

        Extension.Contents("DirectQueryForSQL24.png"),

        Extension.Contents("DirectQueryForSQL32.png")

    },

    Icon32 = {

        Extension.Contents("DirectQueryForSQL32.png"),

        Extension.Contents("DirectQueryForSQL40.png"),

        Extension.Contents("DirectQueryForSQL48.png"),

        Extension.Contents("DirectQueryForSQL64.png")

    }

];

0 REPLIES 0

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.