下面是我写的代码测试:
1
<% @Transaction = Required %>
2
<% Option Explicit %>
3
<%
4
5
Dim con1, con2
6
Dim rs1, rs2
7
8
On Error Resume Next
9
Randomize
10
11
' Open Connection
12
Set con1 = Server.CreateObject("ADODB.Connection")
13
Set con2 = Server.CreateObject("ADODB.Connection")
14
15
con1.Open "provider=sqloledb.1; data source=192.168.107.102; user id=sa; password=123456; initial catalog=northwind"
16
con2.Open "provider=sqloledb.1; data source=192.168.107.97; user id=sa; password=sa; initial catalog=northwind"
17
18
' Open Recordset
19
Set rs1 = Server.CreateObject("ADODB.Recordset")
20
Set rs2 = Server.CreateObject("ADODB.Recordset")
21
22
rs1.Open "SELECT * FROM T_ADO1", con1, 1, 3
23
rs2.Open "SELECT * FROM T_ADO2", con2, 1, 3
24
25
' AddNew Record
26
rs1.AddNew
27
rs1("num") = Rnd() * 100
28
rs1.Update
29
30
rs2.AddNew
31
rs2("num") = Rnd() * 100
32
rs2.Update
33
34
' Raise Error Or Not
35
If Request.QueryString("error") = 1 Then
36
tempNumber = CInt("abc")
37
End If
38
39
' If Error Occured, Rollback Transaction
40
If Err.Number <> 0 Then
41
ObjectContext.SetAbort
42
Response.Write Err.Number & "<br>" & Err.Description
43
Else
44
Response.Write "OK"
45
End If
46
47
' Close Recordset
48
If Not (rs1 Is Nothing) Then
49
rs1.Close
50
End If
51
If Not (rs2 Is Nothing) Then
52
rs2.Close
53
End If
54
55
Set rs1 = Nothing
56
Set rs2 = Nothing
57
58
59
' Close Connection
60
If Not (con1 Is Nothing) Then
61
con1.Close
62
End If
63
If Not (con2 Is Nothing) Then
64
con2.Close
65
End If
66
67
Set con1 = Nothing
68
Set con2 = Nothing
69
70
%>

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
