-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModule1.cs
37 lines (32 loc) · 1.04 KB
/
Module1.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
using System.Data;
using System.Data.OleDb;
using System.Windows.Forms;
namespace 로그인
{
static class Module1
{
private static OleDbConnection cn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0; Data Source = |DataDirectory|\database.accdb");
public static void Connect()
{
if (cn.State == ConnectionState.Closed)
cn.Open();
}
public static bool InsertUpdateDelete(string sql)
{
Connect();
var cmd = new OleDbCommand(sql, cn);
return cmd.ExecuteNonQuery() > 0;
}
public static bool IsConfirm(string message)
{
return MessageBox.Show(message, "Confirm ?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
}
public static DataTable QueryAsDataTable(string sql)
{
var da = new OleDbDataAdapter(sql, cn);
var ds = new DataSet();
da.Fill(ds, "result");
return ds.Tables["result"];
}
}
}