1
'
----------------------------------------------------------------------------
2
'
函数原型:OpenConn(ByRef dbConn)
3
'
功能说明:根据指定的数据库路径打开一个连接
4
'
参数类型:dbConn待打开的数据库连接对象,已经定义的变量
5
'
返 回 值:无
6
'
创建日期:2004年5月20日
7
'
最后修改:2004年5月20日
8
'
----------------------------------------------------------------------------
9
Function
OpenConn(ByRef dbConn)
10
If
TypeName
(dbConn)
=
"
Connection
"
Then
11
If
dbConn.State
<>
adStateClosed
Then
dbConn.Close
12
dbConn.Open MM_Conn_String
13
Exit
Function
14
End
If
15
If
TypeName
(dbConn)
=
"
Empty
"
Then
16
Set
dbConn
=
Server.CreateObject(
"
ADODB.Connection
"
)
17
dbConn.Open MM_Conn_String
18
Else
19
Err.Raise vbObjectError
+
1
,
"
OpenConn(dbConn,strDbPath)
"
,
"
dbConn参数必须是空或者已经存在Connection对象的实例 [
"
&
TypeName
(dbConn)
&
"
]
"
20
End
If
21
End Function
22
'
----------------------------------------------------------------------------
23
'
函数原型:CloseConn(ByRef dbConn)
24
'
功能说明:关闭指定的连接,并且释放资源
25
'
参数类型:dbConn待关闭的数据库连接对象,已经定义的变量
26
'
返 回 值:无
27
'
创建日期:2004年5月20日
28
'
最后修改:2004年5月20日
29
'
----------------------------------------------------------------------------
30
Public
Function
CloseConn(ByRef dbConn)
31
If
TypeName
(dbConn)
<>
"
Connection
"
Then
32
Err.Raise vbObjectError
+
2
,
"
CloseConn(dbConn)
"
,
"
dbConn参数必须是Connection对象的实例 [
"
&
TypeName
(dbConn)
&
"
]
"
33
End
If
34
If
dbConn.State
<>
adStateClosed
Then
dbConn.Close
35
Set
dbConn
=
Nothing
36
End Function
37
'
----------------------------------------------------------------------------
38
'
函数原型:OpenCmd(ByRef cmdTemp,ByRef cnnTemp)
39
'
功能说明:打开一个Command对象
40
'
参数类型:cmdTemp 待代开的Command对象
41
'
cnnTemp 指定的连接对象
42
'
返 回 值:无
43
'
创建日期:2004年5月20日
44
'
最后修改:2004年5月20日
45
'
----------------------------------------------------------------------------
46
Public
Function
OpenCmd(ByRef cmdTemp,ByRef cnnTemp)
47
If
TypeName
(cnnTemp)
<>
"
Connection
"
Then
48
Err.Raise vbObjectError
+
7
,
"
OpenCmd()
"
,
"
打开Command对象时未指定正确的Connection对象 [
"
&
TypeName
(cnnTemp)
&
"
]
"
49
Exit
Function
50
End
If
51
If
cnnTemp.State
=
adStateClosed
Then
52
Err.Raise vbObjectError
+
8
,
"
OpenCmd()
"
,
"
打开Command对象时指定的Connection对象未正确打开
"
53
Exit
Function
54
End
If
55
If
TypeName
(cmdTemp)
=
"
Command
"
Then
56
Set
cmdTemp.ActiveConnection
=
cnnTemp
57
cmdTemp.CommandType
=
adCmdStoredProc
58
Exit
Function
59
End
If
60
If
TypeName
(cmdTemp)
=
"
Empty
"
Then
61
Set
cmdTemp
=
Server.CreateObject(
"
ADODB.Command
"
)
62
Set
cmdTemp.ActiveConnection
=
cnnTemp
63
cmdTemp.CommandType
=
adCmdStoredProc
64
Else
65
Err.Raise vbObjectError
+
9
,
"
OpenCmd(cmdTemp,cnnTemp)
"
,
"
OpenCmd函数的cmdTemp参数必须是空或者已经定义的RecordSet对象 [
"
&
TypeName
(rstTemp)
&
"
]
"
66
End
If
67
End Function
68
'
----------------------------------------------------------------------------
69
'
函数原型:CloseCmd(ByRef cmdTemp)
70
'
功能说明:关闭指定的Command对象并且释放资源
71
'
参数类型:cmdTemp待关闭的Command对象,已经定义的变量
72
'
返 回 值:无
73
'
创建日期:2004年5月20日
74
'
最后修改:2004年5月20日
75
'
----------------------------------------------------------------------------
76
Public
Function
CloseCmd(ByRef cmdTemp)
77
If
TypeName
(cmdTemp)
<>
"
Command
"
Then
78
Err.Raise vbObjectError
+
10
,
"
CloseCmd(cmdTemp)
"
,
"
cmdTemp参数必须是已定义的Command对象 [
"
&
TypeName
(dbConn)
&
"
]
"
79
Else
80
Set
cmdTemp
=
Nothing
81
End
If
82
End Function
83
![None.gif](/Images/OutliningIndicators/None.gif)
2
![None.gif](/Images/OutliningIndicators/None.gif)
3
![None.gif](/Images/OutliningIndicators/None.gif)
4
![None.gif](/Images/OutliningIndicators/None.gif)
5
![None.gif](/Images/OutliningIndicators/None.gif)
6
![None.gif](/Images/OutliningIndicators/None.gif)
7
![None.gif](/Images/OutliningIndicators/None.gif)
8
![None.gif](/Images/OutliningIndicators/None.gif)
9
![None.gif](/Images/OutliningIndicators/None.gif)
10
![None.gif](/Images/OutliningIndicators/None.gif)
11
![None.gif](/Images/OutliningIndicators/None.gif)
12
![None.gif](/Images/OutliningIndicators/None.gif)
13
![None.gif](/Images/OutliningIndicators/None.gif)
14
![None.gif](/Images/OutliningIndicators/None.gif)
15
![None.gif](/Images/OutliningIndicators/None.gif)
16
![None.gif](/Images/OutliningIndicators/None.gif)
17
![None.gif](/Images/OutliningIndicators/None.gif)
18
![None.gif](/Images/OutliningIndicators/None.gif)
19
![None.gif](/Images/OutliningIndicators/None.gif)
20
![None.gif](/Images/OutliningIndicators/None.gif)
21
![None.gif](/Images/OutliningIndicators/None.gif)
22
![None.gif](/Images/OutliningIndicators/None.gif)
23
![None.gif](/Images/OutliningIndicators/None.gif)
24
![None.gif](/Images/OutliningIndicators/None.gif)
25
![None.gif](/Images/OutliningIndicators/None.gif)
26
![None.gif](/Images/OutliningIndicators/None.gif)
27
![None.gif](/Images/OutliningIndicators/None.gif)
28
![None.gif](/Images/OutliningIndicators/None.gif)
29
![None.gif](/Images/OutliningIndicators/None.gif)
30
![None.gif](/Images/OutliningIndicators/None.gif)
31
![None.gif](/Images/OutliningIndicators/None.gif)
32
![None.gif](/Images/OutliningIndicators/None.gif)
33
![None.gif](/Images/OutliningIndicators/None.gif)
34
![None.gif](/Images/OutliningIndicators/None.gif)
35
![None.gif](/Images/OutliningIndicators/None.gif)
36
![None.gif](/Images/OutliningIndicators/None.gif)
37
![None.gif](/Images/OutliningIndicators/None.gif)
38
![None.gif](/Images/OutliningIndicators/None.gif)
39
![None.gif](/Images/OutliningIndicators/None.gif)
40
![None.gif](/Images/OutliningIndicators/None.gif)
41
![None.gif](/Images/OutliningIndicators/None.gif)
42
![None.gif](/Images/OutliningIndicators/None.gif)
43
![None.gif](/Images/OutliningIndicators/None.gif)
44
![None.gif](/Images/OutliningIndicators/None.gif)
45
![None.gif](/Images/OutliningIndicators/None.gif)
46
![None.gif](/Images/OutliningIndicators/None.gif)
47
![None.gif](/Images/OutliningIndicators/None.gif)
48
![None.gif](/Images/OutliningIndicators/None.gif)
49
![None.gif](/Images/OutliningIndicators/None.gif)
50
![None.gif](/Images/OutliningIndicators/None.gif)
51
![None.gif](/Images/OutliningIndicators/None.gif)
52
![None.gif](/Images/OutliningIndicators/None.gif)
53
![None.gif](/Images/OutliningIndicators/None.gif)
54
![None.gif](/Images/OutliningIndicators/None.gif)
55
![None.gif](/Images/OutliningIndicators/None.gif)
56
![None.gif](/Images/OutliningIndicators/None.gif)
57
![None.gif](/Images/OutliningIndicators/None.gif)
58
![None.gif](/Images/OutliningIndicators/None.gif)
59
![None.gif](/Images/OutliningIndicators/None.gif)
60
![None.gif](/Images/OutliningIndicators/None.gif)
61
![None.gif](/Images/OutliningIndicators/None.gif)
62
![None.gif](/Images/OutliningIndicators/None.gif)
63
![None.gif](/Images/OutliningIndicators/None.gif)
64
![None.gif](/Images/OutliningIndicators/None.gif)
65
![None.gif](/Images/OutliningIndicators/None.gif)
66
![None.gif](/Images/OutliningIndicators/None.gif)
67
![None.gif](/Images/OutliningIndicators/None.gif)
68
![None.gif](/Images/OutliningIndicators/None.gif)
69
![None.gif](/Images/OutliningIndicators/None.gif)
70
![None.gif](/Images/OutliningIndicators/None.gif)
71
![None.gif](/Images/OutliningIndicators/None.gif)
72
![None.gif](/Images/OutliningIndicators/None.gif)
73
![None.gif](/Images/OutliningIndicators/None.gif)
74
![None.gif](/Images/OutliningIndicators/None.gif)
75
![None.gif](/Images/OutliningIndicators/None.gif)
76
![None.gif](/Images/OutliningIndicators/None.gif)
77
![None.gif](/Images/OutliningIndicators/None.gif)
78
![None.gif](/Images/OutliningIndicators/None.gif)
79
![None.gif](/Images/OutliningIndicators/None.gif)
80
![None.gif](/Images/OutliningIndicators/None.gif)
81
![None.gif](/Images/OutliningIndicators/None.gif)
82
![None.gif](/Images/OutliningIndicators/None.gif)
83
![None.gif](/Images/OutliningIndicators/None.gif)