-
Notifications
You must be signed in to change notification settings - Fork 1
/
MSSQLDB.cs
97 lines (80 loc) · 2.49 KB
/
MSSQLDB.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
using System.Data.Common;
using System.Data.SqlServerCe;
using System.Windows;
using System.Data.SqlClient;
namespace CheckCasher
{
class MSSQLDB : SQLDB
{
SqlCeConnection conn = null;
string connstr = "Datasource="+Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)+"\\CheckCasher.sdf;password=";
public MSSQLDB()
{
SqlCeEngine en = null;
try
{
en = new SqlCeEngine(connstr);
//en.CreateDatabase();
//createTables();
}
catch (SqlCeException e)
{
//MessageBox.Show(e.GetBaseException().StackTrace);
//MessageBox.Show(e.GetBaseException().Message);
}
catch (Exception e)
{
MessageBox.Show(e.GetBaseException().Message + " " + e.GetBaseException().StackTrace);
}
}
public void close()
{
conn.Close();
}
public void connect()
{
conn = new SqlCeConnection(connstr);
conn.Open();
}
public int ExecuteNonQuery(string sql)
{
connect();
SqlCeCommand cmd = conn.CreateCommand();
cmd.CommandText = sql;
int res = cmd.ExecuteNonQuery();
close();
return res;
}
public DbDataReader ExecuteQuery(string sql)
{
connect();
SqlCeCommand cmd = conn.CreateCommand();
cmd.CommandText = sql;
SqlCeDataReader rdr = cmd.ExecuteReader();
return rdr;
}
public DbDataReader GetImage(string sql)
{
connect();
SqlCeCommand cmd = conn.CreateCommand();
cmd.CommandText = sql;
SqlCeDataReader rdr = cmd.ExecuteReader();
return rdr;
}
public int UpdateImage(string sql, object data, string param)
{
connect();
SqlCeCommand cmd = conn.CreateCommand();
cmd.CommandText = sql;
cmd.Parameters.Add(new SqlCeParameter(param, data));
int res = cmd.ExecuteNonQuery();
close();
return res;
}
}
}