From 87214c46e7c211d7e29209725d1b15468f67285a Mon Sep 17 00:00:00 2001 From: Riku Virtanen Date: Mon, 12 Feb 2024 08:56:29 +0200 Subject: [PATCH] Fixed null parameter --- .../Frends.MicrosoftSQL.ExecuteQueryToFile.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile.cs b/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile.cs index 9504485..b5eb969 100644 --- a/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile.cs +++ b/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile.cs @@ -38,15 +38,15 @@ public static async Task ExecuteQueryToFile([PropertyTab] Input input, [ { foreach (var parameter in input.QueryParameters) { + if (parameter.Value is null) + parameter.Value = DBNull.Value; + if (parameter.SqlDataType is SqlDataTypes.Auto) { command.Parameters.AddWithValue(parameterName: parameter.Name, value: parameter.Value); } else { - if (parameter.Value is null) - parameter.Value = DBNull.Value; - var sqlDbType = (SqlDbType)Enum.Parse(typeof(SqlDbType), parameter.SqlDataType.ToString()); var commandParameter = command.Parameters.Add(parameter.Name, sqlDbType); commandParameter.Value = parameter.Value;