ChrisCompleteCodeTrunk
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
|
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Action_Tire_Payment_Processor
{
public static class Database
{
public static SqlConnection sql = null;
public static string ConnectionString = "";
public static void Init()
{
MaintainTables();
SqlConnectionStringBuilder csb = new SqlConnectionStringBuilder();
csb.DataSource = Settings.GetOption("DBSERVER");
csb.InitialCatalog = Settings.GetOption("DBNAME");
try
{
csb.IntegratedSecurity = bool.Parse(Settings.GetOption("DBWINDOWS"));
}
catch
{
csb.IntegratedSecurity = false;
}
if (!csb.IntegratedSecurity)
{
csb.UserID = Settings.GetOption("DBUSER");
csb.Password = Settings.GetOption("DBPASSWORD");
}
ConnectionString = csb.ConnectionString;
sql = new SqlConnection(csb.ConnectionString);
}
public static void Open()
{
Close();
try
{
sql.Open();
}
catch (Exception ex)
{
MessageBox.Show("Unable to open database connection: " + ex.Message);
}
}
public static void Close()
{
try
{
sql.Close();
}
catch
{
}
}
public static DataTable Query(SqlCommand cmd)
{
Open();
SqlDataReader reader = cmd.ExecuteReader();
DataTable results = new DataTable();
results.Load(reader);
cmd.Dispose();
Close();
return results;
}
public static void NonQuery(SqlCommand cmd)
{
Open();
cmd.ExecuteNonQuery();
cmd.Dispose();
Close();
}
public static void MaintainTables()
{
}
}
}
|
Revision |
Author |
Commited |
Message |
1
|
BBDSCHRIS
|
Wed 22 Aug, 2018 20:08:03 +0000 |
|