SqlServerDB_dotNET.Core 1.0.0

dotnet add package SqlServerDB_dotNET.Core --version 1.0.0
                    
NuGet\Install-Package SqlServerDB_dotNET.Core -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SqlServerDB_dotNET.Core" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SqlServerDB_dotNET.Core" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="SqlServerDB_dotNET.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SqlServerDB_dotNET.Core --version 1.0.0
                    
#r "nuget: SqlServerDB_dotNET.Core, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SqlServerDB_dotNET.Core@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SqlServerDB_dotNET.Core&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=SqlServerDB_dotNET.Core&version=1.0.0
                    
Install as a Cake Tool

SqlServerDB_dotNET.Core (Modern .NET)

SqlServerDB_dotNET.Core è una libreria di alto livello che semplifica la connessione a
Microsoft SQL Server e l’esecuzione di query in .NET moderno.

Questo pacchetto è progettato esclusivamente per .NET moderno (net10.0) ed è basato su
Microsoft.Data.SqlClient, il provider ufficiale e supportato per SQL Server.

⚠️ Nota Per applicazioni .NET Framework (4.x) esiste un pacchetto legacy separato.
Questo package NON supporta .NET Framework.


✨ Funzionalità

  • Connessione semplificata a SQL Server
  • Supporto a:
    • SQL Authentication
    • Windows Authentication
  • Wrapper ad alto livello per:
    • SELECT (DataTable)
    • INSERT / UPDATE / DELETE
  • Recupero informazioni:
    • versione SQL Server
    • timeout di connessione
    • numero record interessati
    • ultimo ID inserito
  • Gestione errori centralizzata
  • Compatibile con applicazioni cross-platform (Windows, Linux, macOS)

📦 Requisiti

  • .NET 10.0
  • SQL Server (locale o remoto)
  • Driver incluso: Microsoft.Data.SqlClient

📥 Installazione

CLI

dotnet add package SqlServerDB_dotNET.Core

Package Manager

Install-Package SqlServerDB_dotNET.Core

🚀 Quick Start

using System;
using System.Data;
using SqlServerDB;

class Program
{
    static void Main()
    {
        string connectionString =
            "Data Source=SERVER\\INSTANCE;" +
            "Initial Catalog=MyDatabase;" +
            "User ID=sa;" +
            "Password=MyPassword;" +
            "Trusted_Connection=False;" +
            "Encrypt=True;" +
            "TrustServerCertificate=True;" +
            "Connect Timeout=60;";

        using DBConnection db = new DBConnection(connectionString);

        if (!db.IsConnected())
        {
            Console.WriteLine("Connessione non riuscita.");
            return;
        }

        Console.WriteLine($"SQL Server Version: {db.GetVersion()}");

        DataTable table = db.SelectTable("SELECT TOP 10 * FROM MyTable;");
        foreach (DataRow row in table.Rows)
        {
            Console.WriteLine(row[0]);
        }
    }
}

🔐 Connection string – esempi

SQL Authentication (consigliata)

Data Source=SERVER\INSTANCE;
Initial Catalog=MyDatabase;
User ID=sa;
Password=MyPassword;
Trusted_Connection=False;
Encrypt=True;
TrustServerCertificate=True;

Windows Authentication

Data Source=SERVER\INSTANCE;
Initial Catalog=MyDatabase;
Trusted_Connection=True;
Encrypt=True;
TrustServerCertificate=True;

❗ Non mescolare Trusted_Connection=True con User ID / Password.


📚 API – Panoramica

Costruttore

  • DBConnection(string connectionString)

Proprietà

  • string Server
  • string Database
  • string UserID
  • string Password

Metodi

  • bool IsConnected()
  • string GetVersion()
  • int GetConnectionTimeout()
  • DataTable SelectTable(string sql)
  • bool sql_query(string sql)
  • string[] sql_error()
  • int GetLastInsertedRowID()
  • int GetNumRecordsAffected()

La classe implementa IDisposable: usa sempre using.


🔒 Sicurezza

Gli esempi utilizzano SQL testuali per semplicità.

In produzione è fortemente consigliato:

  • usare query parametriche
  • usare stored procedure
  • non loggare connection string complete

🛠️ Troubleshooting

Errore SSL / Certificato

Aggiungi:

Encrypt=True;TrustServerCertificate=True;

Login failed for user

  • verifica Mixed Mode Authentication
  • verifica username/password
  • verifica istanza (SERVER\SQLEXPRESS)

IsConnected() restituisce false

  • controlla sql_error()
  • verifica firewall / TCP/IP
  • aumenta Connect Timeout

🧭 Compatibilità

Piattaforma Supporto
.NET 10
.NET 8 / 7 / 6
.NET Framework
Windows
Linux
macOS

📄 Licenza

Consulta la pagina NuGet del pacchetto per dettagli su licenza e changelog.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 182 1/16/2026

Extensions on the SqlServerDB .NetFramework.