Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Welcome to our homepage about client programming to interact with Microsoft SQL Server, and with Azure SQL Database in the cloud. This article provides the following information:
In any given language, the code that connects to SQL Server is almost identical to the code for connecting to Azure SQL Database.
For details about the connection strings for connecting to Azure SQL Database, see:
In the following table, each language image is a link to detail about using the language with SQL Server. Each link jumps to a later section in this article.
The following article is devoted to the download and install various SQL connection drivers, for use by programming languages:
The .NET managed languages, such as C# and Visual Basic, are the most common users of ADO.NET. ADO.NET is a casual name for a subset of .NET Framework classes.
Example | Description |
---|---|
Proof of concept connecting to SQL using ADO.NET | A small code example focused on connecting and querying SQL Server. |
Connect resiliently to SQL with ADO.NET | Retry logic in a code example, because connections can occasionally experience moments of connectivity loss. Retry logic applies well to connections maintained through the internet into any cloud database, such as to Azure SQL Database. |
Azure SQL Database: Demonstration of how to use .NET Core on Windows/Linux/macOS to create a C# program, to connect and query | Azure SQL Database example. |
Area | Description |
---|---|
C# using ADO.NET | Root of our documentation. |
Namespace: System.Data | A set of classes used for ADO.NET. |
Namespace: Microsoft.Data.SqlClient | The set of classes used for Microsoft .NET Data Provider for SQL Server |
Entity Framework (EF) provides Object-Relational Mapping (ORM). ORM makes it easier for your Object-Oriented Programming (OOP) source code to manipulate data that was retrieved from a relational SQL database.
EF has direct or indirect relationships with the following technologies:
=>
operator in C#.The start page for Entity Framework introduces EF with a description similar to this:
Entity Framework is a name shared by two separate source code branches. One EF branch is older, and its source code can now be maintained by the public. The other EF is new. The two EFs are described next:
Version | Description |
---|---|
EF 6.x | Microsoft first released EF in August 2008. In March 2015, Microsoft announced that EF 6.x was the final version that Microsoft would develop. Microsoft released the source code into the public domain. Initially EF was part of .NET Framework. But EF 6.x was removed from .NET Framework. EF 6.x source code on GitHub, in repository aspnet/EntityFramework6 |
EF Core | Microsoft released the newly developed EF Core in June 2016. EF Core is designed for better flexibility and portability. EF Core can run on operating systems beyond just Microsoft Windows. And EF Core can interact with databases beyond just Microsoft SQL Server and other relational databases. C# code examples: Getting Started with Entity Framework Core Getting started with EF Core on .NET Framework with an Existing Database |
EF and related technologies are powerful, and are a lot to learn for the developer who wants to master the entire area.
Microsoft provides a Java Database Connectivity (JDBC) driver for use with SQL Server (or with Azure SQL Database). It is a Type 4 JDBC driver, and it provides database connectivity through the standard JDBC application program interfaces (APIs).
Example | Description |
---|---|
Code examples | Code examples that teach about data types, result sets, and large data. |
Connection URL Sample | Describes how to use a connection URL to connect to SQL Server. Then use it to use a SQL statement to retrieve data. |
Data Source Sample | Describes how to use a data source to connect to SQL Server. Then use a stored procedure to retrieve data. |
Use Java to query an Azure SQL database | Azure SQL Database example. |
The JDBC documentation includes the following major areas:
Area | Description |
---|---|
Java Database Connectivity (JDBC) | Root of our JDBC documentation. |
Reference | Interfaces, classes, and members. |
Programming Guide for JDBC SQL Driver | Configuration information, along with code examples. |
With Node.js you can connect to SQL Server from Windows, Linux, or macOS. The root of our Node.js documentation is here.
The Node.js connection driver for SQL Server is implemented in JavaScript. The driver uses the TDS protocol, which is supported by all modern versions of SQL Server. The driver is an open-source project, available on GitHub.
Example | Description |
---|---|
Proof of concept connecting to SQL using Node.js | Bare bones source code for connecting to SQL Server, and executing a query. |
Azure SQL database: Use Node.js to query | Example for Azure SQL Database in the cloud. |
Open database connectivity (ODBC) was developed in the 1990s, and it predates .NET Framework. ODBC is designed to be independent of any particular database system, and independent of operating system.
Over the years numerous ODBC drivers have been created and released by groups within and outside of Microsoft. The range of drivers involve several client programming languages. The list of data targets goes well beyond SQL Server.
Some other connectivity drivers use ODBC internally.
The ODBC content in this section focuses on accessing either SQL Server or Azure SQL Database, from C++. The following table lists an approximate outline of the major documentation for ODBC.
Area | Subarea | Description |
---|---|---|
ODBC for C++ | Root of our documentation. | |
Linux-macOS | Information about using ODBC on the Linux or macOS operating systems. | |
Windows | Information about using ODBC on the Windows operating system. | |
Administration | The administrative tool for managing ODBC data sources. | |
Microsoft | Various ODBC drivers that are created and provided by Microsoft. | |
Conceptual and reference | Conceptual information about the ODBC interface, in addition to traditional reference. | |
Conceptual and reference | Appendixes | State transition tables, ODBC cursor library, and more. |
Conceptual and reference | Develop app | Functions, handles, and much more. |
Conceptual and reference | Develop driver | How to develop your own ODBC driver, if you have a specialized data source. |
Conceptual and reference | Install | ODBC installation, subkeys, and more. |
Conceptual and reference | Syntax | APIs for setup, installer, translation, and data access. |
You can use PHP to interact with SQL Server. The root of our PHP documentation is here.
Example | Description |
---|---|
Proof of concept connecting to SQL using PHP | A small code example focused on connecting and querying SQL Server. |
Connect resiliently to SQL with PHP | Retry logic in a code example, because connections through the Internet and the cloud can occasionally experience moments of connectivity loss. |
Azure SQL database: Use PHP to query | Azure SQL Database example. |
You can use Python to interact with SQL Server.
Example | Description |
---|---|
Proof of concept connecting to SQL with Python using pyodbc | A small code example focused on connecting and querying SQL Server. |
Azure SQL database: Use Python to query | Azure SQL Database example. |
Area | Description |
---|---|
Python to SQL Server | Root of our documentation. |
pymssql driver | Microsoft doesn't maintain or test the pymssql driver. The pymssql connection driver is a simple interface to SQL databases, for use in Python programs. Pymssql builds on top of FreeTDS to provide a Python DB-API (PEP-249) interface to Microsoft SQL Server. |
pyodbc driver | The pyodbc connection driver is an open-source Python module that makes accessing ODBC databases simple. It implements the DB API 2.0 specification, but is packed with even more Pythonic convenience. |
You can use Ruby to interact with SQL Server. The root of our Ruby documentation is here.
Example | Description |
---|---|
Proof of concept connecting to SQL with Ruby | A small code example focused on connecting and querying SQL Server. |
Azure SQL database: Use Ruby to query | Azure SQL Database example. |
This section provides links about other development options. These include using these same languages for Azure development in general. The information goes beyond targeting just Azure SQL Database and Microsoft SQL Server.
Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayTraining
Learning path
Develop data-driven applications by using Azure SQL Database - Training
Learn how to develop data-driven applications by using Microsoft Azure SQL Database. DP-3020
Certification
Microsoft Certified: Azure Developer Associate - Certifications
Build end-to-end solutions in Microsoft Azure to create Azure Functions, implement and manage web apps, develop solutions utilizing Azure storage, and more.