(DBConnectionPool) 数据连接池类
1
Imports System.IO
2
Imports System.Xml
3
Imports System.Data.OleDb
4
Imports System.Collections
5
Imports System.Threading
6
Imports ItardaLib
7
Imports ItardaLib.Utility
8![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
9
Public Class DBConnectionPool
10![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
11
Public Shared dBConnection As Object
12
Public Shared dBTransaction As OleDbTransaction
13![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
14
Public Shared Function GetDBConnection() As Object
15
' DB连接
16
If TypeName(dBConnection) = "Nothing" Then
17
dBConnection = ItardaApplication.ConnectionManager.Connect()
18
BeginTransaction()
19
AddHandler DirectCast(dBConnection, OleDbConnection).StateChange, AddressOf StateChangeEventHandler
20
AddHandler DirectCast(dBConnection, OleDbConnection).InfoMessage, AddressOf OleDbInfoMessageEventHandler
21
End If
22
Return (dBConnection)
23![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
24
End Function
25![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
26
Public Shared Sub StateChangeEventHandler( _
27
ByVal sender As Object, _
28
ByVal e As StateChangeEventArgs _
29
)
30
' MsgBox(e.CurrentState)
31![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
32![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
33
End Sub
34![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
35![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
36![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
37![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
38
Public Shared Sub OleDbInfoMessageEventHandler( _
39
ByVal sender As Object, _
40
ByVal e As OleDbInfoMessageEventArgs _
41
)
42
MsgBox(e.Message)
43
End Sub
44![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
45![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
46
Public Shared Function GetDBConnection(ByVal p_blReconnect As Boolean) As Object
47![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
48
If p_blReconnect Then
49
CloseDBConnection()
50
End If
51
Return GetDBConnection()
52![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
53
End Function
54![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
55
Public Shared Function CloseDBConnection() As Boolean
56
ItardaApplication.ConnectionManager.Disconnect()
57
dBConnection = Nothing
58
Return (True)
59
End Function
60![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
61
Public Shared Function BeginTransaction() As Boolean
62![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
63
dBTransaction = DirectCast(dBConnection, OleDbConnection).BeginTransaction()
64![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
65
End Function
66
Public Shared Function SystemLock() As Boolean
67
' SQL
68
Dim strSql As String
69
' Command
70
Dim objOleDbCommand As OleDbCommand
71![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
72
strSql = "UPDATE ""LOCK"" SET ""LOCKCODE"" = ""LOCKCODE"" WHERE ""LOCKCODE"" = '00'"
73![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
74
objOleDbCommand = New OleDbCommand(strSql, DirectCast(dBConnection, OleDbConnection))
75
objOleDbCommand.Transaction = DBConnectionPool.dBTransaction
76![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
77
objOleDbCommand.Prepare()
78
objOleDbCommand.ExecuteNonQuery()
79![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
80![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
81
End Function
82
Public Shared Function EndTransaction(ByVal p_Commit As Boolean) As Boolean
83
If p_Commit Then
84
dBTransaction.Commit()
85
Else
86
Try
87
dBTransaction.Rollback()
88
Catch e As Exception
89
End Try
90
End If
91
End Function
92![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
93![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
94
End Class
95![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
7
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
8
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
9
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
10
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
11
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
12
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
13
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
14
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
15
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
16
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
17
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
18
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
19
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
20
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
21
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
22
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
23
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
24
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
25
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
26
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
27
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
28
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
29
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
30
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
31
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
32
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
33
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
34
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
35
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
36
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
37
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
38
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
39
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
40
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
41
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
42
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
43
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
44
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
45
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
46
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
47
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
48
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
49
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
50
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
51
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
52
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
53
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
54
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
55
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
56
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
57
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
58
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
59
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
60
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
61
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
62
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
63
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
64
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
65
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
66
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
67
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
68
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
69
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
70
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
71
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
72
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
73
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
74
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
75
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
76
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
77
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
78
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
79
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
80
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
81
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
82
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
83
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
84
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
85
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
86
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
87
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
88
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
89
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
90
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
91
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
92
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
93
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
94
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
95
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)