-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSQLUtil.cs
More file actions
65 lines (53 loc) · 1.69 KB
/
SQLUtil.cs
File metadata and controls
65 lines (53 loc) · 1.69 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
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
using System.Text;
using System.Data;
using System.Data.OleDb;
using System.Collections.Generic;
namespace AutoRun
{
public partial class SQLUtil : Object
{
private OleDbCommand command;
private static SQLUtil instance;
static SQLUtil()
{
SQLUtil.instance = new SQLUtil();
return;
}
private SQLUtil()
{
return;
}
public static SQLUtil Instance
{
get
{
return SQLUtil.instance;
}
}
public void Connect(String Host, String Port, String Service, String Login, String Password)
{
this.command = new OleDbCommand();
this.command.Connection = new OleDbConnection();
this.command.Connection.ConnectionString = String.Format("Provider=MSDAORA;Data Source=(DESCRIPTION = (LOAD_BALANCE = ON) (ADDRESS = (PROTOCOL = TCP) (HOST = {0}) (PORT = {1})) (CONNECT_DATA = (SERVICE_NAME = {2})));User ID={3};Password={4}", Host, Port, Service, Login, Password);
this.command.Connection.Open();
return;
}
public DataTable Execute(String sql)
{
DataTable Result;
this.command.CommandText = String.Format("{0}", sql);
Result = new DataTable();
Result.Load(this.command.ExecuteReader());
return Result;
}
public void Disconnect()
{
this.command.Connection.Close();
this.command.Connection.ConnectionString = String.Empty;
this.command.Connection = null;
this.command = null;
return;
}
}
}