{"id":24979579,"url":"https://github.com/gaepdit/db-helper","last_synced_at":"2026-04-29T09:06:44.814Z","repository":{"id":43172729,"uuid":"59774638","full_name":"gaepdit/db-helper","owner":"gaepdit","description":"A library to simplify interactions with a SQL Server database","archived":false,"fork":false,"pushed_at":"2025-10-29T17:56:53.000Z","size":288,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-20T18:09:00.296Z","etag":null,"topics":["database","sql","sql-server"],"latest_commit_sha":null,"homepage":"","language":"Visual Basic .NET","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gaepdit.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-05-26T18:43:48.000Z","updated_at":"2025-10-29T17:56:56.000Z","dependencies_parsed_at":"2024-08-23T16:17:03.792Z","dependency_job_id":"75fd4397-f8ad-4591-ad2e-c8a2d45fdb6b","html_url":"https://github.com/gaepdit/db-helper","commit_stats":{"total_commits":125,"total_committers":1,"mean_commits":125.0,"dds":0.0,"last_synced_commit":"c0a617cb0b67b6334d7463cca710facca78d058c"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/gaepdit/db-helper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaepdit%2Fdb-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaepdit%2Fdb-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaepdit%2Fdb-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaepdit%2Fdb-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gaepdit","download_url":"https://codeload.github.com/gaepdit/db-helper/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaepdit%2Fdb-helper/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32418235,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T06:29:02.080Z","status":"ssl_error","status_checked_at":"2026-04-29T06:29:00.631Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["database","sql","sql-server"],"created_at":"2025-02-04T01:19:40.843Z","updated_at":"2026-04-29T09:06:44.808Z","avatar_url":"https://github.com/gaepdit.png","language":"Visual Basic .NET","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DB Helper\n\nThe purpose of this library is to simplify interactions with a SQL Server database. \n\n[![NuGet](https://img.shields.io/nuget/v/GaEpd.DbHelper.svg?maxAge=86400)](https://www.nuget.org/packages/GaEpd.DbHelper/) \n\n[![.NET Test](https://github.com/gaepdit/db-helper/actions/workflows/dotnet-test.yml/badge.svg)](https://github.com/gaepdit/enforcement-orders/actions/workflows/dotnet.yml)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=gaepdit_db-helper\u0026metric=alert_status)](https://sonarcloud.io/summary/new_code?id=gaepdit_db-helper)\n[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=gaepdit_db-helper\u0026metric=ncloc)](https://sonarcloud.io/summary/new_code?id=gaepdit_db-helper)\n\n## What is this?\n\nThere are two classes available:\n\n* The `DBHelper` class has many functions available for interacting with a SQL Server database. These functions take care of the tedious parts of querying data or running commands on the database, such as handling connection objects and transactions. There are separate sets of functions depending on whether a SQL query string is used as input or the name of a stored procedure.\n\n* There is also a `DBUtilities` class with some static functions that simplify working with DBNull values and table-valued SQL parameters.\n\n## How do I install it?\n\nTo install DB Helper, search for \"GaEpd.DbHelper\" in the NuGet package manager or run the following command in the [Package Manager Console](https://docs.nuget.org/consume/package-manager-console):\n\n`PM\u003e Install-Package GaEpd.DbHelper`\n\n## Using the `DBHelper` class\n\nThe `DBHelper` class must be instantiated with a connection string:\n\n```vb\nPublic DB As New GaEpd.DBHelper(connectionString)\n```\n\nOptionally, you can configure [connection retry logic](https://learn.microsoft.com/en-us/sql/connect/ado-net/configurable-retry-logic-sqlclient-introduction) and provide it to the `DBHelper` constructor:\n\n```vb\nDim options As New SqlRetryLogicOption() With {\n    .NumberOfTries = 3,\n    .DeltaTime = TimeSpan.FromSeconds(5),\n    .MaxTimeInterval = TimeSpan.FromSeconds(15),\n    .AuthorizedSqlCondition = Function(x) String.IsNullOrEmpty(x) OrElse Regex.IsMatch(x, \"\\b(SELECT)\\b\", RegexOptions.IgnoreCase)\n}\n\nconnectionRetryProvider = SqlConfigurableRetryFactory.CreateFixedRetryProvider(options)\n\nDB = New GaEpd.DBHelper(connectionString, connectionRetryProvider)\n```\n\n### Query string functions\n\nThese functions require a SQL query or command plus an optional SQL parameter or array of SQL parameters. When running a non-query command, such as `INSERT` or `UPDATE`, an optional output parameter will contain the number of rows affected.\n\n**Example 1:** Simple query\n\n```vb\nDim query as String = \"select States from StatesTable\"\nDim states as DataTable = DB.GetDataTable(query)\n```\n\n**Example 2:** Query with one SQL parameter\n\n```vb\nDim query as String = \"select UserName from UserTable where UserId = @id\"\nDim parameter As New SqlParameter(\"@id\", MyUserId)\nDim userName as String = DB.GetSingleValue(Of String)(query, parameter)\n```\n\n**Example 3:** Command with multiple SQL parameters\n\n```vb\nDim query as String = \"update FacilityTable set Name = @name where FacilityId = @id\"\nDim parameterArray As SqlParameter() = {\n    New SqlParameter(\"@name\", MyNewFacilityName),\n    New SqlParameter(\"@id\", MyFacilityId)\n}\nDim result as Boolean = DB.RunCommand(query, parameterArray)\n```\n\n**Example 4:** Count rows affected by command\n\n```vb\nDim query as String = \"update CompanyTable set Status = @status where State = @state\"\nDim parameterArray As SqlParameter() = {\n    New SqlParameter(\"@status\", MyNewStatus),\n    New SqlParameter(\"@state\", AffectedState)\n}\nDim rowsAffected as Integer\nDim result as Boolean = DB.RunCommand(query, parameterArray, rowsAffected)\nConsole.WriteLine(rowsAffected \u0026 \" rows affected.\")\n```\n\n### Stored procedure functions\n\nThese functions require the name of a stored procedure instead of a SQL query, but otherwise are very similar to the query functions. These functions all start with \"SP\" in the name. \n\nAn optional output parameter will contain the integer RETURN value of the stored procedure. (Often, a return value of 0 indicates success and a nonzero value indicates failure, but this depends on the particular stored procedure.)\n\n**Example 1:** Specifying INPUT and OUTPUT SQL parameters\n\n```vb\nDim spName as String = \"RetrieveFacilitiesByCounty\"\nDim returnParam As New SqlParameter(\"@total\", SqlDbType.Int) With {\n    .Direction = ParameterDirection.Output\n}\nDim parameterArray As SqlParameter() = {\n    New SqlParameter(\"@county\", MyCounty),\n    returnParam\n}\nDim facilities as DataTable = DB.SPGetDataTable(spName, parameterArray)\nDim total As Integer = returnParam.Value\n```\n\n**Example 2:** Querying for a DataSet and using RETURN value\n\n```vb\nDim spName As String = \"GetMyData\"\nDim returnValue As Integer\nDim dataSet As DataSet = DB.SPGetDataSet(spName, returnValue:=returnValue)\n```\n\n## Using the `DBUtilities` class\n\nThis class does not need to be instantiated and only includes shared functions:\n\n* `GetNullable(Of T)` converts a database value to a generic, useable .NET value, handling DBNull appropriately\n* `GetNullableString` converts a database value to a string, handling DBNull appropriately\n* `GetNullableDateTime` converts a database value to a nullable DateTime, handling DBNull appropriately\n* `TvpSqlParameter(Of T)` converts an IEnumerable of type T to a structured, table-valued SqlParameter\n\n## Changelog\n\n### Breaking changes\n\n#### Version 5.1\n\nThe SqlClient package was migrated from System.Data.SqlClient to the new [Microsoft.Data.SqlClient](https://www.nuget.org/packages/Microsoft.Data.SqlClient/). This update introduces some breaking changes. \n\nPlease see the [Microsoft announcement](https://github.com/dotnet/announcements/issues/322) and the [porting cheat sheet](https://github.com/dotnet/SqlClient/blob/main/porting-cheat-sheet.md) for more information and guidance on updating your code.\n\n#### Version 5\n\nThe namespace/prefix was changed from `EpdIt` to `GaEpd`, which is a reserved prefix on nuget.org. This required publishing as a new package and deprecating the old package.\n\n#### Version 3\n\nThe `forceAddNullableParameters` parameter has been removed. `DBNull.Value` will be sent for `SqlParameter`'s that evaluate to null (`Nothing` in VB.NET).\n\nThe output parameter convenience functions have been removed. If you need an output SQL parameter, just add it as you would normally add any other parameter.\n\n#### Version 2\n\nThe `forceAddNullableParameters` parameter now defaults to `true`. If this parameter is not set (or is manually set to `true`), then `DBNull.Value` will be sent for `SqlParameter`'s that evaluate to `Nothing`. To return to the default behavior of dropping such parameters, you must manually set `forceAddNullableParameters` to `false`.\n\n## Developer Notes\n\nTo publish a package update to NuGet.org, build a Release version, navigate to the project folder, and run:\n\n```\nnuget push GaEpd.DbHelper.x.x.x.nupkg -Source https://api.nuget.org/v3/index.json\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaepdit%2Fdb-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgaepdit%2Fdb-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaepdit%2Fdb-helper/lists"}