vb.netsystem.datamicrosoft-fabric

Using System.Data.Sqlclient instead of Microsoft.Data.SqlClient when connecting to a Fabric datawarehouse


Using this example: https://robkerr.ai/query-fabric-table-csharp/

I can connect to my sqlserver Fabric Warehouse in Azure trough VS Code when using Microsoft.Data.SqlClient

My question is this : Is this possible to achive using System.Data.SqlClient? I just can't make it work.

(This is part of a rather big solution and using Microsoft.Data.SqlClient raises all kind of other problems)

This code works fine

Imports Microsoft.Data.SqlClient
Dim connectionString As String = "Data Source=theCave.datawarehouse.pbidedicated.windows.net,1433;
                               Initial Catalog=TreASURE;
                               Authentication=ActiveDirectoryPassword;
                               User Id=AliBaba@robber.no;  
                               Password=SesamSesam"

Dim conn As SqlConnection = New SqlConnection(connectionString)
conn.Open()

But when replacing Microsoft.Data.SqlClient with System.Data.Sqlclient I just cant make it work.

tnx


Solution

  • Both System.Data.SqlClient and Microsoft.Data.SqlClient can connect to Fabric SQL endpoints.

    Fabric SQL endpoints don't support SQL Auth or Windows Auth. Only Entra ID auth (formerly called AAD auth).

    Microsoft.Data.SqlClient natively understands and implements several EntraId authentication flows. System.Data.SqlClient only understands a couple of Entra ID auth flows natively. But you can fetch an access token for Azure SQL Database using any auth flow you need, and set the .AccessToken property on a System.Data.SqlClient.SqlConnection to connect.

    Follow the docs here: Connect using a Microsoft Entra ID access token