![]() |
VOOZH | about |
The CData ADO.NET Provider for Azure Synapse is a standard ADO.NET Provider that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time and bidirectional access to Azure Synapse.
The ADO.NET Provider provides a SQL interface for Azure Synapse; this tutorial shows how to use the Provider to create, retrieve, update, and delete Azure Synapse data.
Once you have acquired the necessary connection properties, accessing Azure Synapse data in PowerShell can be enabled in three steps.
In addition to providing authentication (see below), set the following properties to connect to a Azure Synapse database:
Connect to Azure Synapse using the following properties:
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Azure Synapse\lib\System.Data.CData.AzureSynapse.dll")
Connect to Azure Synapse:
$conn= New-Object System.Data.CData.AzureSynapse.AzureSynapseConnection("User=myuser;Password=mypassword;Server=localhost;Database=Northwind;")
$conn.Open()
Instantiate the AzureSynapseDataAdapter, execute an SQL query, and output the results:
$sql="SELECT Id, ProductName from Products"
$da= New-Object System.Data.CData.AzureSynapse.AzureSynapseDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable
$da.Fill($dt)
$dt.Rows | foreach {
Write-Host $_.id $_.productname
}
$cmd = New-Object System.Data.CData.AzureSynapse.AzureSynapseCommand("UPDATE Products SET ProductName='Konbu' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.AzureSynapse.AzureSynapseParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()
$cmd = New-Object System.Data.CData.AzureSynapse.AzureSynapseCommand("INSERT INTO Products (ProductName) VALUES (@myProductName)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.AzureSynapse.AzureSynapseParameter("@myProductName","Konbu")))
$cmd.ExecuteNonQuery()
$cmd = New-Object System.Data.CData.AzureSynapse.AzureSynapseCommand("DELETE FROM Products WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.AzureSynapse.AzureSynapseParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()
CodeProject
Download a free trial of the Azure Synapse Data Provider to get started:
Download NowLearn more:
👁 Azure Synapse IconRapidly create and deploy powerful .NET applications that integrate with Azure Synapse.