{"id":22366430,"url":"https://github.com/microsoft/tdslib","last_synced_at":"2025-08-17T01:34:16.200Z","repository":{"id":65976269,"uuid":"538418951","full_name":"microsoft/TdsLib","owner":"microsoft","description":"Open implementation of the TDS protocol (version 7.4) in managed C# code.","archived":false,"fork":false,"pushed_at":"2022-10-15T21:50:22.000Z","size":140,"stargazers_count":19,"open_issues_count":2,"forks_count":8,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-08-17T01:34:15.680Z","etag":null,"topics":["dotnet","sqlserver","sre","tds"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/microsoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null}},"created_at":"2022-09-19T09:07:53.000Z","updated_at":"2025-02-27T19:14:28.000Z","dependencies_parsed_at":"2023-02-19T19:31:09.232Z","dependency_job_id":null,"html_url":"https://github.com/microsoft/TdsLib","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/microsoft/TdsLib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2FTdsLib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2FTdsLib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2FTdsLib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2FTdsLib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/microsoft","download_url":"https://codeload.github.com/microsoft/TdsLib/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2FTdsLib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270796217,"owners_count":24647319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dotnet","sqlserver","sre","tds"],"created_at":"2024-12-04T18:11:43.921Z","updated_at":"2025-08-17T01:34:16.179Z","avatar_url":"https://github.com/microsoft.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TdsLib\n\n[![Nuget](https://img.shields.io/nuget/v/Microsoft.Data.Tools.TdsLib)](https://www.nuget.org/packages/Microsoft.Data.Tools.TdsLib)\n\n\nThis repository contains an open implementation of the [TDS protocol](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-tds/) (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.\n\nThis 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.\n\n## Requirements\n\n- [dotnet](https://dotnet.microsoft.com/en-us/)\n- [net standard 2.0](https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0)\n\n## Code structure\n\n```text\nsrc\n  Microsoft.Data.Tools.TdsLib - TdsLib code\n    Buffer - Buffer class to handle type conversion\n    IO - Connection related classes\n    Messages - Logical message format used to generate Packets to be sent to SQL Server\n    Packets - Packet related classes\n    Payloads - Message Payloads\n    Tokens - Tokens that can be received from SQL server\n\ntest\n  Microsoft.Data.Tools.TdsLib.UnitTest - Unit tests\n  Microsoft.Data.Tools.TdsLib.IntegrationTest - Integration tests\n```\n\n## Example\n\n### Establish a TDS connection and login to a SQL server\n\n```csharp\nusing Microsoft.Data.Tools.TdsLib;\nusing Microsoft.Data.Tools.TdsLib.IO.Connection.Tcp;\nusing Microsoft.Data.Tools.TdsLib.Messages;\nusing Microsoft.Data.Tools.TdsLib.Packets;\nusing Microsoft.Data.Tools.TdsLib.Payloads.Login7;\nusing Microsoft.Data.Tools.TdsLib.Payloads.PreLogin;\nusing Microsoft.Data.Tools.TdsLib.Tokens.Error;\n\nstring hostname = \"sqlserver.contoso.net\";\nint port = 1433;\n\nusing TdsClient client = new TdsClient(new TcpServerEndpoint(hostname, port));\n\n// Send PreLogin message\nawait client.MessageHandler.SendMessage(new Message(PacketType.PreLogin)\n{\n    Payload = new PreLoginPayload(encrypt: true)\n});\n\n// Receive PreLogin message\nvar preLoginResponseMessage = await client.MessageHandler.ReceiveMessage(b =\u003e new PreLoginPayload(b));\n\n// Perform TLS handshake\nawait client.PerformTlsHandshake();\n\n// Prepare Login7 message\nLogin7Payload login7Payload = new Login7Payload()\n{\n    Hostname = hostname,\n    ServerName = \"MyServerName\",\n    AppName = \"MyAppName\",\n    Language = \"us_english\",\n    Database = \"MyDatabaseName\",\n    //Username,\n    //Password\n};\n\nlogin7Payload.TypeFlags.AccessIntent = OptionAccessIntent.ReadWrite;\n\nMessage login7Message = new Message(PacketType.Login7) { Payload = login7Payload };\n\n// Send Login7 message\nawait client.MessageHandler.SendMessage(login7Message);\n\n// Receive Login response tokens\nawait client.TokenStreamHandler.ReceiveTokensAsync(tokenEvent =\u003e\n{\n    if (tokenEvent.Token is ErrorToken errorToken)\n    {\n        // Error was received from the server\n    }\n});\n\n// 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.\n```\n\n## Contributing\n\nThis project welcomes contributions and suggestions.  Most contributions require you to agree to a\nContributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us\nthe rights to use your contribution. For details, visit \u003chttps://cla.opensource.microsoft.com\u003e.\n\nWhen you submit a pull request, a CLA bot will automatically determine whether you need to provide\na CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions\nprovided by the bot. You will only need to do this once across all repos using our CLA.\n\nThis project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).\nFor more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or\ncontact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.\n\n## Trademarks\n\nThis project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft\ntrademarks or logos is subject to and must follow\n[Microsoft's Trademark \u0026 Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).\nUse of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.\nAny use of third-party trademarks or logos are subject to those third-party's policies.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Ftdslib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicrosoft%2Ftdslib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Ftdslib/lists"}