写给yzx110的一个实例,仅作参考!
1
public bool DBCommandWrapper(string commandText, OracleParameterCollection Parameters) {
2
try {
3
this.dbCommand = new OracleCommand(commandText, (OracleConnection) this.dbConnection);
4
5
this.dbConnection.Open();
6
7
8
9
10
foreach (OracleParameter op in Parameters) {
11
if (op.OracleType ==OracleType.Char ) {
12
this.dbCommand.Parameters.Add(op.ParameterName, OracleType.Char).Value = Convert.ToByte(op.Value);
13
}
14
else {
15
if (op.OracleType == OracleType.VarChar) {
16
op.Value = op.Value==null ? OracleString.Null : op.Value;
17
this.dbCommand.Parameters.Add(op.ParameterName, op.DbType).Value = op.Value;
18
}
19
else {
20
this.dbCommand.Parameters.Add(op.ParameterName, op.OracleType).Value = op.Value;
21
}
22
}
23
}
24
25
this.dbCommand.ExecuteNonQuery();
26
27
28
29
return true;
30
}
31
catch (Exception ex) {
32
33
sb.Append("Error Message: ");
38
sb.Append(ex.Message);
39
sb.Append("\r\n");
40
return false;
41
}
42
finally {
43
this.dbCommand.Parameters.Clear();
44
this.dbConnection.Close();
45
}
46
47
}

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

38

39

40

41

42

43

44

45

46

47
