How To
How to Use SqlDataReader to process multiple result sets in C#
By Tan Lee Published on Mar 19, 2025 304
In this article, I'll demonstrate how to use the SqlDataReader ADO.NET class in two scenarios involving multiple result sets:
How to use SqlBulkCopy in C#
By Tan Lee Published on Dec 13, 2024 754
SqlBulkCopy is a class in the System.Data.SqlClient namespace in C# that provides an efficient way to bulk load data into SQL Server databases.
How to Install and configure a Windows Service from the command line
By Tan Lee Published on Mar 19, 2025 211
This article explains how to install, configure, query, and uninstall a Windows Service using command line utilities installutil.exe and sc.exe.
How to Deserialize JSON that Contains an Embedded JSON String in C#
By Tan Lee Published on Mar 19, 2025 280
In this article, I'll demonstrate how to handle deserializing JSON that contains an embedded JSON string, which I'll refer to as a "JSON package." This concept is like receiving a gift box (the JSON package) that contains a smaller gift (the embedded JSON data) inside it.
SqlException: Cannot insert explicit value for identity column
By Tan Lee Published on Mar 19, 2025 189
This error occurs because the table contains an identity column, and you're attempting to manually set a value for it. With an identity column, the value is automatically generated by the system during the insert, which is why you're not allowed to provide a value for this column.
How to find all the dependencies of a table in SQL Server
By Tan Lee Published on Mar 14, 2025 462
When working with a database in SQL Server, understanding the dependencies between tables, views, procedures, and other objects is essential. Often, you might need to track how tables are interconnected, especially when trying to identify which other tables, views, or stored procedures depend on a particular table.
How to Find Objects Referencing a Table in SQL Server
By Tan Lee Published on Mar 14, 2025 421
Renaming a table in SQL Server can be a tricky task, especially when there are numerous objects such as columns, stored procedures, functions, or views that rely on that table.
How to use JsonConverterFactory in C#
By Tan Lee Published on Mar 14, 2025 587
To use a JsonConverterFactory in C#, you need to create a custom JsonConverterFactory subclass and implement the necessary methods.
How to serialize non-public properties using System.Text.Json
By Tan Lee Published on Mar 14, 2025 353
By default, System.Text.Json.JsonSerializer only serializes public properties. If you need to serialize non-public properties, you have two main options:
The JSON value could not be converted to System.DateTime
By Tan Lee Published on Mar 14, 2025 413
When using System.Text.Json to deserialize a DateTime value, an error occurs if the value is not in the expected format. The default expected format is the ISO-8601-1:2019 format, such as 2025-03-12T12:35:34+00:00.
Case sensitivity in SQL Server
By Tan Lee Published on Mar 14, 2025 342
In SQL Server, the collation property controls case sensitivity. Case sensitivity can affect how data is sorted and queried, even down to column names, which must match exactly in a case-sensitive database setting.
Try/finally with no catch block in C#
By Tan Lee Published on Mar 14, 2025 277
In C#, a try/finally block is particularly useful when you need to guarantee certain actions will always be executed at the end of a method, regardless of whether an exception was thrown.