Microsoft.Data.Tools.TdsLib 0.2.2089.23

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
.NET Standard 2.0
dotnet add package Microsoft.Data.Tools.TdsLib --version 0.2.2089.23
NuGet\Install-Package Microsoft.Data.Tools.TdsLib -Version 0.2.2089.23
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Microsoft.Data.Tools.TdsLib" Version="0.2.2089.23" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Microsoft.Data.Tools.TdsLib --version 0.2.2089.23
#r "nuget: Microsoft.Data.Tools.TdsLib, 0.2.2089.23"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Microsoft.Data.Tools.TdsLib as a Cake Addin
#addin nuget:?package=Microsoft.Data.Tools.TdsLib&version=0.2.2089.23

// Install Microsoft.Data.Tools.TdsLib as a Cake Tool
#tool nuget:?package=Microsoft.Data.Tools.TdsLib&version=0.2.2089.23

Microsoft.Data.Tools.TdsLib

Open implementation of the TDS protocol (version 7.4) in managed C# code. It is not a full implementation, current support is focused on the login steps and some generic TDS features. It does not support normal data streams or T-SQL commands.

This library is mainly used for probing and for diagnosing TDS connections but can be used to manually construct and handle any step of a TDS connection. It can also be used to mock TDS clients.

Example

Establish a TDS connection and login to a SQL server

using Microsoft.Data.Tools.TdsLib;
using Microsoft.Data.Tools.TdsLib.IO.Connection.Tcp;
using Microsoft.Data.Tools.TdsLib.Messages;
using Microsoft.Data.Tools.TdsLib.Packets;
using Microsoft.Data.Tools.TdsLib.Payloads.Login7;
using Microsoft.Data.Tools.TdsLib.Payloads.PreLogin;
using Microsoft.Data.Tools.TdsLib.Tokens.Error;

string hostname = "sqlserver.contoso.net";
int port = 1433;

using TdsClient client = new TdsClient(new TcpServerEndpoint(hostname, port));

// Send PreLogin message
await client.MessageHandler.SendMessage(new Message(PacketType.PreLogin)
{
    Payload = new PreLoginPayload(encrypt: true)
});

// Receive PreLogin message
var preLoginResponseMessage = await client.MessageHandler.ReceiveMessage(b => new PreLoginPayload(b));

// Perform TLS handshake
await client.PerformTlsHandshake();

// Prepare Login7 message
Login7Payload login7Payload = new Login7Payload()
{
    Hostname = hostname,
    ServerName = "MyServerName",
    AppName = "MyAppName",
    Language = "us_english",
    Database = "MyDatabaseName",
    //Username,
    //Password
};

login7Payload.TypeFlags.AccessIntent = OptionAccessIntent.ReadWrite;

Message login7Message = new Message(PacketType.Login7) { Payload = login7Payload };

// Send Login7 message
await client.MessageHandler.SendMessage(login7Message);

// Receive Login response tokens
await client.TokenStreamHandler.ReceiveTokensAsync(tokenEvent =>
{
    if (tokenEvent.Token is ErrorToken errorToken)
    {
        // Error was received from the server
    }
});

// If no error token was received, and SQL server did not close the connection, then the connection to the server is now established and the user is logged in.
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48 net481
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.2.2089.23 202 9/21/2022