-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDBconnection.cs
41 lines (31 loc) · 948 Bytes
/
DBconnection.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace ABC_Institute___Timetable_Generator
{
class DBconnection
{
private String conString = @"SERVER=abcdatabase.mysql.database.azure.com;PORT=3306;DATABASE=mydb;UID=abcadmin@abcdatabase;PASSWORD=ABC@123abc";
private MySqlConnection con;
public MySqlConnection getConnection()
{
try {
MySqlConnection con = new MySqlConnection(conString);
this.con = con;
this.con.Open();
}catch(Exception e)
{
MessageBox.Show("Data Connection Error Occured");
}
return this.con;
}
public void closeConnection()
{
this.con.Close();
}
}
}