SqlServerDbHelper_dotNET 1.0.1
See the version list below for details.
dotnet add package SqlServerDbHelper_dotNET --version 1.0.1
NuGet\Install-Package SqlServerDbHelper_dotNET -Version 1.0.1
<PackageReference Include="SqlServerDbHelper_dotNET" Version="1.0.1" />
paket add SqlServerDbHelper_dotNET --version 1.0.1
#r "nuget: SqlServerDbHelper_dotNET, 1.0.1"
// Install SqlServerDbHelper_dotNET as a Cake Addin #addin nuget:?package=SqlServerDbHelper_dotNET&version=1.0.1 // Install SqlServerDbHelper_dotNET as a Cake Tool #tool nuget:?package=SqlServerDbHelper_dotNET&version=1.0.1
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);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net40 is compatible. net403 was computed. net45 was computed. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. 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.