This repository has been archived by the owner on Sep 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Db.cs
57 lines (46 loc) · 1.45 KB
/
Db.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Data.SqlClient;
using System.Windows.Forms;
using System.Data;
namespace EmployeeManagement
{
class Db
{
public static SqlConnection con = new SqlConnection($"Data Source=DESKTOP-5QEG18K;Initial Catalog=EmployeeDatabase;User ID=xxxx;Password=xxxx");
public static SqlCommand cmd = new SqlCommand(" ", con);
public static DataSet ds;
public static SqlDataAdapter da;
public static BindingSource bs;
public static string sql;
public static void OpenConnection()
{
try
{
if (con.State == ConnectionState.Closed)
{
con.Open();
//MessageBox.Show("Connection Status: " + con.State.ToString());
}
}
catch (Exception ex)
{
MessageBox.Show("Open Connection Error: " + ex.Message);
}
}
public static void CloseConnection()
{
try
{
if (con.State == ConnectionState.Open)
{
con.Close();
//MessageBox.Show("Connection Status: " + con.State.ToString());
}
}
catch (Exception ex)
{
MessageBox.Show("Disconnection Error: " + ex.Message);
}
}
}
}