Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 [email protected];  
                               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

like image 544
perove Avatar asked Oct 30 '25 10:10

perove


1 Answers

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

like image 82
David Browne - Microsoft Avatar answered Nov 03 '25 00:11

David Browne - Microsoft



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!