-
Notifications
You must be signed in to change notification settings - Fork 1
/
MYSQLDB.cs
78 lines (68 loc) · 1.98 KB
/
MYSQLDB.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
using System.Data.Common;
namespace CheckCasher
{
class MYSQLDB : SQLDB
{
MySqlConnection conn = null;
bool lcl = false;
public MYSQLDB(bool lcl)
{
this.lcl = lcl;
}
public MYSQLDB()
{
this.lcl = false;
}
public void close()
{
conn.Close();
}
public void connect()
{
string MyConString;
MyConString = "SERVER=localhost;" + "DATABASE=CheckCasher;" + "UID=root;" + "PASSWORD=;Convert Zero Datetime=true;";
conn = new MySqlConnection(MyConString);
conn.Open();
}
public int ExecuteNonQuery(string sql)
{
connect();
MySqlCommand cmd = conn.CreateCommand();
cmd.CommandText = sql;
int res = cmd.ExecuteNonQuery();
close();
return res;
}
public DbDataReader ExecuteQuery(string sql)
{
connect();
MySqlCommand cmd = conn.CreateCommand();
cmd.CommandText = sql;
MySqlDataReader rdr = cmd.ExecuteReader();
return rdr;
}
public DbDataReader GetImage(string sql)
{
connect();
MySqlCommand cmd = conn.CreateCommand();
cmd.CommandText = sql;
MySqlDataReader rdr = cmd.ExecuteReader();
return rdr;
}
public int UpdateImage(string sql, object data, string param)
{
connect();
MySqlCommand cmd = conn.CreateCommand();
cmd.CommandText = sql;
cmd.Parameters.Add(new MySqlParameter(param, data));
int res = cmd.ExecuteNonQuery();
close();
return res;
}
}
}