Skip to content

Commit 2e4fc54

Browse files
committed
Database Error Exception
1 parent 6be5b48 commit 2e4fc54

19 files changed

+59
-16457
lines changed

.vs/C-Sharf Classes/v15/.suo

21 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.

.vs/C-Sharf Classes/v16/.suo

106 KB
Binary file not shown.

C-Sharf Classes/Classes/Database.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ class Database : Config
4747

4848
// connection string
4949
private static string constring = "server=localhost;uid=" + dbuser + ";pwd='" + dbpassword + "';database=" + dbname;
50+
51+
// MySql Classes
5052
public MySqlConnection con = new MySqlConnection(constring);
5153
MySqlCommand cmd;
5254
MySqlDataReader reader;
@@ -57,15 +59,9 @@ class Database : Config
5759
public Database()
5860
{
5961
con = new MySqlConnection(constring);
60-
try
61-
{
62-
if(con.State == ConnectionState.Closed)
63-
con.Open();
64-
}
65-
catch (Exception ex)
62+
if (con.State == ConnectionState.Closed)
6663
{
67-
Application.Exit();
68-
MessageBox.Show(ex.Message);
64+
con.Open();
6965
}
7066
}
7167

@@ -93,7 +89,7 @@ public void cud(string qry, string msg = "")
9389
if (cmd.ExecuteNonQuery() > 0)
9490
{
9591
if (msg == "")
96-
MessageBox.Show("Transaction Complete!");
92+
MessageBox.Show("Transaction Completed!");
9793
else
9894
MessageBox.Show(msg);
9995
}

C-Sharf Classes/Program.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,19 @@ static class Program
1616
[STAThread]
1717
static void Main()
1818
{
19-
Database db = new Database();
20-
Application.EnableVisualStyles();
21-
Application.SetCompatibleTextRenderingDefault(false);
22-
Application.Run(new frmLogin());
19+
try
20+
{
21+
Database db = new Database();
22+
Application.EnableVisualStyles();
23+
Application.SetCompatibleTextRenderingDefault(false);
24+
Application.Run(new frmLogin());
25+
}
26+
catch(Exception)
27+
{
28+
MessageBox.Show("Database Connection Error! The application will exit.");
29+
System.Environment.Exit(1);
30+
}
31+
2332
}
2433
}
2534
}
512 Bytes
Binary file not shown.
Binary file not shown.
-288 KB
Binary file not shown.

C-Sharf Classes/bin/Debug/MySql.Data.xml

Lines changed: 0 additions & 16426 deletions
This file was deleted.

0 commit comments

Comments
 (0)