Getting Started With dotConnect for SQL Server

Below are some resources to help you maximize your experience with dotConnect for SQL Server.

dotConnect for SQL Server is a versatile enterprise-grade connector that enables access to SQL Server data in .NET applications of all levels. It delivers broad compatibility with SQL Server versions and .NET platforms, and easy integration with a number of IDEs, including Visual Studio.

  • Access to data with no need for any client libraries
  • Full compliance with ADO.NET standards
  • Secure connections to SQL Server via TCP/IP
  • Support for SQL Server-specific data types
  • Integration with Visual Studio

Code examples

using Devart.Data.SqlServer;

public sealed class Program
{
    public static void Main(string[] args)
    {
        try
        {
            string connectionString = "" +
            "Data Source=127.0.0.1;" +
            "User Id=TestUser;" +
            "Password=TestPassword;" +
            "Initial Catalog=TestDb;" +
            "License key=**********";

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                Console.WriteLine("Connection successful!");
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine("An error occurred: " + ex.Message);
        }
    }
}
PM> Install-Package Devart.Data.SqlServer
using Devart.Data.SqlServer;

public sealed class Program
{
    public static void Main(string[] args)
    {
        try
        {
            string connectionString = "" +
            "Data Source=127.0.0.1;" +
            "User Id=TestUser;" +
            "Password=TestPassword;" +
            "Initial Catalog=TestDb;" +
            "License key=**********";

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                Console.WriteLine("Connection successful!");

                const string sql = "SELECT TOP (10) * FROM actor";
                using (SqlCommand command = new SqlCommand(sql, connection))
                using (var reader = command.ExecuteReader())
                {
                    int fields = reader.FieldCount;
                    // Print header
                    for (int i = 0; i < fields; i++)
                    {
                        Console.Write(reader.GetName(i) + (i < fields - 1 ? "\t" : ""));
                    }
                    Console.WriteLine();
                    // Print rows
                    while (reader.Read())
                    {
                        for (int i = 0; i < fields; i++)
                        {
                            object value = reader.IsDBNull(i) ? "(null)" : reader.GetValue(i);
                            Console.Write(value + (i < fields - 1 ? "\t" : ""));
                        }
                        Console.WriteLine();
                    }
                }
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine("An error occurred: " + ex.Message);
        }
    }
}
PM> Install-Package Devart.Data.SqlServer
using Devart.Data.SqlServer;

public sealed class Program
{
    public static void Main(string[] args)
    {
        try
        {
            string connectionString = "" +
            "Data Source=127.0.0.1;" +
            "User Id=TestUser;" +
            "Password=TestPassword;" +
            "Initial Catalog=TestDb;" +
            "License key=**********";

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                Console.WriteLine("Connection successful!");

                // Create SqlLoader instance
                using (SqlLoader loader = new SqlLoader())
                {
                    loader.Connection = connection;
                    loader.TableName = "actor";

                    // Prepare columns
                    loader.CreateColumns();

                    // Add sample data rows using SetValue and NextRow
                    loader.SetValue(0, 1);
                    loader.SetValue(1, "John");
                    loader.SetValue(2, "Doe");
                    loader.SetValue(3, DateTime.Now);
                    loader.NextRow();

                    loader.SetValue(0, 2);
                    loader.SetValue(1, "Jane");
                    loader.SetValue(2, "Smith");
                    loader.SetValue(3, DateTime.Now);
                    loader.NextRow();

                    loader.SetValue(0, 3);
                    loader.SetValue(1, "Bob");
                    loader.SetValue(2, "Johnson");
                    loader.SetValue(3, DateTime.Now);
                    loader.NextRow();

                    // Execute bulk load
                    loader.Close(true); // Sends data to the server
                    Console.WriteLine("Rows loaded successfully.");
                }
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine("An error occurred: " + ex.Message);
        }
    }
}
PM> Install-Package Devart.Data.SqlServer
using Devart.Data.SqlServer;

public sealed class Program
{
    public static async Task Main(string[] args)
    {
        try
        {
            // Replace with your actual connection string
            string connectionString = "" +
            "Data Source=127.0.0.1;" +
            "User Id=TestUser;" +
            "Password=TestPassword;" +
            "Initial Catalog=TestDb;" +
            "License key=**********";

            await using (SqlConnection connection = new SqlConnection(connectionString))
            {
                await connection.OpenAsync();
                Console.WriteLine("Connection successful!");

                const string sql = "SELECT TOP (10) * FROM actor";
                await using (SqlCommand command = new SqlCommand(sql, connection))
                await using (var reader = await command.ExecuteReaderAsync())
                {
                    int fields = reader.FieldCount;
                    // Print header
                    for (int i = 0; i < fields; i++)
                    {
                        Console.Write(reader.GetName(i) + (i < fields - 1 ? "\t" : ""));
                    }
                    Console.WriteLine();
                    // Print rows
                    while (await reader.ReadAsync())
                    {
                        for (int i = 0; i < fields; i++)
                        {
                            object value = await reader.IsDBNullAsync(i) ? "(null)" : reader.GetValue(i);
                            Console.Write(value + (i < fields - 1 ? "\t" : ""));
                        }
                        Console.WriteLine();
                    }
                }
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine("An error occurred: " + ex.Message);
        }
    }
}
PM> Install-Package Devart.Data.SqlServer

How-to articles

.NET Connection String for SQL Server
Learn how to set up connection strings properly when working with dotConnect for SQL Server in .NET applications.
Connect to SQL Server in .NET
Explore how to establish a connection between .NET applications and SQL Server using ADO.NET.
Connect to Azure SQL
Learn how to connect to Azure SQL Databases in a .NET app using C#.
Connect to Google Cloud SQL for SQL Server
Implement robust data access for .NET applications using Google Cloud SQL Server.

Documentation

Licensing
Licensing
A detailed technical reference on embedding license information—a required resource for applications built with dotConnect for SQL Server.
SqlScript
SqlScript
An introduction to SqlScript that lets you run several SQL statements as one script through a single connection, using semicolons to separate statements and events to track progress and handle errors.
SqlLoader
SqlLoader
An overview of SqlLoader, a bulk-loading component for importing large data sets into SQL Server with configurable columns, batching, and transactional options for fast, reliable loads.
SqlDataTable
SqlDataTable
A guide to using SqlDataTable, an in-memory representation of a SQL Server table or query that supports disconnected editing, data binding, and later synchronization with the database.

dotConnect Universal

Get universal access to data from a variety of sources, including SQL Server, Oracle, PostgreSQL, MySQL, SQLite, DB2, InterBase, Microsoft Access, and Firebird. Other servers can be accessed through their ADO.NET, OLE DB and ODBC providers.

FAQ

What is the trial period for dotConnect for SQL Server?

dotConnect for SQL Server offers a fully functional 30-day trial. During this period, you can use and evaluate all features without limitations. After the trial ends, you can purchase a license to keep using the product.

Why do I need to install the product if NuGet is available?

dotConnect for SQL Server provides two sets of assemblies, and the choice depends on your project type:

  • For .NET (.NET Core/.NET 5+) projects: Use the assemblies available via NuGet packages.
  • For .NET Framework projects: Use the Devart assemblies included with the product installer.
Where should I apply my License Key?

Add the License Key parameter to your connection string together with other connection parameters. For more information, see Licensing.

What editions of dotConnect for SQL Server are available, and what's the difference?

There are two editions:

  • Express—Free version with basic connectivity in the .NET Framework only.
  • Developer—Fully functional product version.
Do end-users of my application require a Devart license, or must I pay additional fees for deploying my software?

No, end users do not need a Devart license, and there are no additional deployment fees, as long as you hold a valid Devart license.

According to the EULA, you're allowed to redistribute the following runtime assemblies with your application:

  • Devart.Data.SqlServer.dll
  • Devart.Data.dll

You can include them in your app's folder (such as Bin for web apps) or register them in the GAC. Just make sure they are only used by your solution.

There's no need for a full installation on the target machine, you can also use the "Minimal installation" option provided by the setup.

No other components of dotConnect may be distributed.

How can I update dotConnect to a new version?

To update dotConnect to a new version, you need to reinstall it:

  1. Open Settings > Apps > Installed apps in Windows.
  2. Uninstall the current and any older versions of dotConnect, including Entity Developer and LinqConnect, if installed.
  3. Visit the Customer Portal and download the latest licensed version.
  4. Install the downloaded version and receive the latest features and improvements.
How can I completely remove all previous versions of a product?
  1. Go to Settings > Apps > Installed apps and uninstall:
    • All dotConnect providers
    • Entity Developer
    • LinqConnect
  2. Manually delete any leftover files from the following locations (if they exist):

    GAC folders:

    • C:\Windows\assembly\GAC_MSIL
    • C:\Windows\Microsoft.NET\assembly\GAC_MSIL

    Program files and extensions:

    • C:\Program Files (x86)\Microsoft Visual Studio\...\Community\Common7\IDE\Extensions\Devart
    • C:\Program Files\Microsoft Visual Studio\...\Community\Common7\IDE\Extensions\Devart
    • C:\Program Files (x86)\Devart
    • C:\Program Files\Devart
    • C:\Program Files (x86)\Common Files\Devart
    • C:\Program Files\Common Files\Devart

    Program data folders:

    • C:\ProgramData\Devart\dotConnect
    • C:\ProgramData\Devart\Entity Developer

Removing these ensures a clean system and prevents conflicts during future installations.

dotConnect for SQL Server

Get an enhanced ORM-enabled data provider for SQL Server and develop .NET applications working with SQL Server data quickly and easily!

Try the 30-day trial of the full product. No limits. No card required Start free trial