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

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
