{"id":810,"date":"2025-10-30T15:05:41","date_gmt":"2025-10-30T14:05:41","guid":{"rendered":"https:\/\/www.silverice.it\/IpercubeTechWP1\/?page_id=810"},"modified":"2025-10-30T15:11:09","modified_gmt":"2025-10-30T14:11:09","slug":"sql-functions","status":"publish","type":"page","link":"https:\/\/www.silverice.it\/IpercubeTechWP1\/ipercube-utilities\/sql-functions\/","title":{"rendered":"Sql Functions"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Functions to interact with Micosoft SQL server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Because my library can be referenced by a Framework or Core project, I created two different projects in the same solution that share the same source code but with different target. So one project is targeted to Framework 4.x (where I defined the variable FRAMEWORK) and the other to Core 8 (where I defined the variable CORE)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this case the compiler uses different library for Sql, the classical <em>System.Data.SqlClient<\/em> for Framework project and the more recent <em>Microsoft.Data.SqlClient<\/em> for Core project (where <em>System.Data.SqlClient<\/em> is deprecated).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here the required Imports:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-Geist-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-Geist-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2b2b2b;color:#c7c7c7\">VB<\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>Imports System.Data\nImports System.Reflection\nImports System.Text.RegularExpressions\n\n#If CORE Then\nImports Microsoft.Data.SqlClient\n#ElseIf FRAMEWORK Then\nImports System.Data.SqlClient\n#End If<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D4D4D4\">Imports System.Data<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">Imports System.Reflection<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">Imports System.Text.RegularExpressions<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">#<\/span><span style=\"color: #C586C0\">If<\/span><span style=\"color: #D4D4D4\"> CORE <\/span><span style=\"color: #C586C0\">Then<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">Imports Microsoft.Data.SqlClient<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">#<\/span><span style=\"color: #C586C0\">ElseIf<\/span><span style=\"color: #D4D4D4\"> FRAMEWORK <\/span><span style=\"color: #C586C0\">Then<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">Imports System.Data.SqlClient<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">#<\/span><span style=\"color: #C586C0\">End If<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">The Functions list:<\/p>\n\n\n<ul><li><a href=\"https:\/\/www.silverice.it\/IpercubeTechWP1\/ipercube-utilities\/sql-functions\/checksqlconnection\/\">Check Sql Connection<\/a><\/li><li><a href=\"https:\/\/www.silverice.it\/IpercubeTechWP1\/ipercube-utilities\/sql-functions\/execute-non-query-sql-cmd-signature-1\/\">Execute Non Query Sql Cmd (Signature 1)<\/a><\/li><li><a href=\"https:\/\/www.silverice.it\/IpercubeTechWP1\/ipercube-utilities\/sql-functions\/execute-non-query-sql-cmd-signature-2\/\">Execute Non Query Sql Cmd (Signature 2)<\/a><\/li><li><a href=\"https:\/\/www.silverice.it\/IpercubeTechWP1\/ipercube-utilities\/sql-functions\/executequeryondatatable\/\">Execute Query On DataTable<\/a><\/li><li><a href=\"https:\/\/www.silverice.it\/IpercubeTechWP1\/ipercube-utilities\/sql-functions\/loadsqltable\/\">Load Sql Table<\/a><\/li><li><a href=\"https:\/\/www.silverice.it\/IpercubeTechWP1\/ipercube-utilities\/sql-functions\/readsqltablechunk\/\">Read Sql Table Chunk<\/a><\/li><li><a href=\"https:\/\/www.silverice.it\/IpercubeTechWP1\/ipercube-utilities\/sql-functions\/sqlbulkwrite\/\">Sql Bulk Write<\/a><\/li><li><a href=\"https:\/\/www.silverice.it\/IpercubeTechWP1\/ipercube-utilities\/sql-functions\/tableexists\/\">Table Exists<\/a><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Functions to interact with Micosoft SQL server. Because my library can be referenced by a Framework or Core project, I created two different projects in the same solution that share the same source code but with different target. So one project is targeted to Framework 4.x (where I defined the variable FRAMEWORK) and the other [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":155,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-810","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.silverice.it\/IpercubeTechWP1\/wp-json\/wp\/v2\/pages\/810","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silverice.it\/IpercubeTechWP1\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.silverice.it\/IpercubeTechWP1\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.silverice.it\/IpercubeTechWP1\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silverice.it\/IpercubeTechWP1\/wp-json\/wp\/v2\/comments?post=810"}],"version-history":[{"count":5,"href":"https:\/\/www.silverice.it\/IpercubeTechWP1\/wp-json\/wp\/v2\/pages\/810\/revisions"}],"predecessor-version":[{"id":821,"href":"https:\/\/www.silverice.it\/IpercubeTechWP1\/wp-json\/wp\/v2\/pages\/810\/revisions\/821"}],"up":[{"embeddable":true,"href":"https:\/\/www.silverice.it\/IpercubeTechWP1\/wp-json\/wp\/v2\/pages\/155"}],"wp:attachment":[{"href":"https:\/\/www.silverice.it\/IpercubeTechWP1\/wp-json\/wp\/v2\/media?parent=810"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}