SqlServerDbHelper_dotNET 1.0.3
dotnet add package SqlServerDbHelper_dotNET --version 1.0.3
NuGet\Install-Package SqlServerDbHelper_dotNET -Version 1.0.3
<PackageReference Include="SqlServerDbHelper_dotNET" Version="1.0.3" />
paket add SqlServerDbHelper_dotNET --version 1.0.3
#r "nuget: SqlServerDbHelper_dotNET, 1.0.3"
// Install SqlServerDbHelper_dotNET as a Cake Addin #addin nuget:?package=SqlServerDbHelper_dotNET&version=1.0.3 // Install SqlServerDbHelper_dotNET as a Cake Tool #tool nuget:?package=SqlServerDbHelper_dotNET&version=1.0.3
Example: using SqlServerDbHelper;
string server = @"INSTANCE\SQLEXPRESS"; string database = "DEMODB"; string username = "sa"; string password = "";
string connectionString = @"Data Source="+ server + ";Initial Catalog="+ database + "; Trusted_Connection=True;User ID="+ username + ";Password="+ password + ""; DbHelper dbHelper = new DbHelper(connectionString);
Console.WriteLine("IsConnected: " + dbHelper.IsConnected()); if (dbHelper == null || !dbHelper.IsConnected()) { Console.WriteLine("Connessione non valida."); return; } Console.WriteLine("GetVersion: " + dbHelper.GetVersion()); Console.WriteLine("ConnectionString: " + connectionString); Console.WriteLine("GetConnectionTimeout: " + dbHelper.GetConnectionTimeout()); Console.WriteLine("Host: " + dbHelper.Server); Console.WriteLine("Database: " + dbHelper.Database); Console.WriteLine("UserID: " + dbHelper.UserID); Console.WriteLine("Password: " + dbHelper.Password);
string strTableNameAndSchema = "MyDB";
// Skip the backup if already exists if (dbHelper.IfBackupExists(connectionString, strTableNameAndSchema)) return;
string backUpLocation = @"D:\Backup"; string databaseName = strTableNameAndSchema; string backUpFileName = databaseName + "" + DateTime.Now.ToString("ddMMyyyy_HHmm") + "" + "sql2022";
string fileName = @"D:\Backup\backup.bak"; string istname = server;
// Restore if (dbHelper.RestoreDB(fileName, istname, databaseName, server) < 0) Console.WriteLine($"SQL Database Restore Failed");
// Backup if (dbHelper.BackupDatabase(backUpLocation, backUpFileName, databaseName, server, connectionString)) {
}
// Drop dbHelper.DropDatabase(connectionString);
// Start dbHelper.StartService();
// Stop dbHelper.StopService();
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net472 is compatible. net48 was computed. net481 was computed. |
-
- Microsoft.SqlServer.SqlManagementObjects (>= 160.2004021.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Extensions on the SqlServerDB .NetFramework.