-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsqlConn.cs
More file actions
52 lines (43 loc) · 1.32 KB
/
Copy pathsqlConn.cs
File metadata and controls
52 lines (43 loc) · 1.32 KB
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
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ASSIGNMENT3.DAL
{
internal class sqlConn :IDisposable
{
String _connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
sqlConn connection = null;
public sqlConn()
{
connection = new sqlConn(_connStr);
connection.Open();
}
public int ExcueteQuery(String sqlQuery)
{
MySqlCommand command = new MySqlCommand(sqlQuery, connection);
int res = command.ExecuteNonQuery();
return res;
}
public Object ExcueteScalar(String sqlQuery)
{
MySqlCommand command = new MySqlCommand(sqlQuery, connection);
return command.ExecuteScalar();
}
public MySqlDataReader ExcueteReader(String sqlQuery)
{
MySqlCommand command = new MySqlCommand(sqlQuery, connection);
return command.ExecuteReader();
}
public void Dispose()
{
if (connection != null && connection.State == System.Data.ConnectionState.Open)
{
connection.Close();
}
}
}
}