0xR4IF / 0xR4IF/HotelMakers

Create Database-Connection

Offen
#9 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
C#
Sterne
1
Forks
0
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Skapa enskild class för en database connection.

EX.
using Npgsql;

public class DatabaseConnection
{
private static string connectionString"Host=localhost;Port=5455;Username=postgres;Password=postgres;Database=hotel8";

public static NpgsqlConnection GetConnection()
{
NpgsqlConnection connection = new NpgsqlConnection(connectionString);
connection.Open();
return connection;
} // Denna metod är för att vi ska kunna öppna connection om och om i andra classes.

public static void CloseConnection(NpgsqlConnection connection)
{
if (connection.State == System.Data.ConnectionState.Open)
{
connection.Close();
} } // Denna metod är för att vi ska kunna stänga connection i slutet av varje class.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.