-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMysqlHelper.cs
35 lines (32 loc) · 1.12 KB
/
MysqlHelper.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
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
namespace CheckInAPI
{
public class MysqlHelper
{
//private static MySqlConnection conn;
static public DataSet Query(string constr,string sql)
{
MySqlConnection conn = new MySqlConnection(constr);
conn.Open();
DataSet reds = new DataSet();
MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(sql, conn);
//cmd.ExecuteReader
MySql.Data.MySqlClient.MySqlDataAdapter da = new MySql.Data.MySqlClient.MySqlDataAdapter(cmd);
da.Fill(reds);
return reds;
}
static public int Exec(string constr, string sql)
{
MySqlConnection conn = new MySqlConnection(constr);
conn.Open();
DataSet reds = new DataSet();
MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(sql, conn);
return cmd.ExecuteNonQuery();
}
}
}