1 Public Function ReadTable(ByVal TableName,ByVal Condition,ByVal GetFieldNames)
Public Function ReadTable(ByVal TableName,ByVal Condition,ByVal GetFieldNames)
2 On Error Resume Next
   On Error Resume Next
3 Dim rstGetValue,Sql,BaseCondition,arrTemp,arrStr,TempStr,i
   Dim rstGetValue,Sql,BaseCondition,arrTemp,arrStr,TempStr,i
4 TempStr = "" : arrStr = ""
   TempStr = "" : arrStr = ""
5 '给出SQL条件语句
   '给出SQL条件语句
6 BaseCondition = ValueToSql(TableName,Condition,1)
   BaseCondition = ValueToSql(TableName,Condition,1)
7 '读取数据
'读取数据
8 Set rstGetValue = Server.CreateObject("ADODB.Recordset")
   Set rstGetValue = Server.CreateObject("ADODB.Recordset")
9 Sql = "Select "&GetFieldNames&" From ["&TableName&"] Where "&BaseCondition
   Sql = "Select "&GetFieldNames&" From ["&TableName&"] Where "&BaseCondition
10 rstGetValue.Open Sql,idbConn,1,1
   rstGetValue.Open Sql,idbConn,1,1
11 If rstGetValue.RecordCount > 0 Then
   If rstGetValue.RecordCount > 0 Then
12 If Instr(GetFieldNames,",")>0 Then
      If Instr(GetFieldNames,",")>0 Then
13 arrTemp = Split(GetFieldNames,",")
         arrTemp = Split(GetFieldNames,",")
14 For i = 0 To Ubound(arrTemp)
         For i = 0 To Ubound(arrTemp)
15 If i<>0 Then arrStr = arrStr &Chr(112)&Chr(112)&Chr(113)
            If i<>0 Then arrStr = arrStr &Chr(112)&Chr(112)&Chr(113)
16 arrStr = arrStr & rstGetValue.Fields(i).Value
            arrStr = arrStr & rstGetValue.Fields(i).Value
17 Next
         Next
18 TempStr = Split(arrStr,Chr(112)&Chr(112)&Chr(113))
         TempStr = Split(arrStr,Chr(112)&Chr(112)&Chr(113))
19 Else
      Else
20 TempStr = rstGetValue.Fields(0).Value
         TempStr = rstGetValue.Fields(0).Value
21 End If
      End If
22 End If
   End If
23 If Err.number <> 0 Then
   If Err.number <> 0 Then
24 idbErr = idbErr & "获取数据出错!<br />"
      idbErr = idbErr & "获取数据出错!<br />"
25 If debug Then idbErr = idbErr & "错误信息:"& Err.Description
      If debug Then idbErr = idbErr & "错误信息:"& Err.Description
26 rstGetValue.close()
      rstGetValue.close()
27 Set rstGetValue = Nothing
      Set rstGetValue = Nothing
28 Exit Function
      Exit Function
29 End If
   End If
30 rstGetValue.close()
   rstGetValue.close()
31 Set rstGetValue = Nothing
   Set rstGetValue = Nothing
32 ReadTable = TempStr
   ReadTable = TempStr
33 End Function
End Function
34
35 Public Function C(ByVal ObjRs)
Public Function C(ByVal ObjRs)
36 ObjRs.close()
   ObjRs.close()
37 Set ObjRs = Nothing
   Set ObjRs = Nothing
38 End Function
End Function
39
40 Private Function ValueToSql(ByVal TableName, ByVal ValueList, ByVal sType)
Private Function ValueToSql(ByVal TableName, ByVal ValueList, ByVal sType)
41 Dim StrTemp
   Dim StrTemp
42 StrTemp = ValueList
   StrTemp = ValueList
43 If IsArray(ValueList) Then
   If IsArray(ValueList) Then
44 StrTemp = ""
      StrTemp = ""
45 Dim rsTemp, CurrentField, CurrentValue, i
      Dim rsTemp, CurrentField, CurrentValue, i
46 Set rsTemp = Server.CreateObject("adodb.recordset")
      Set rsTemp = Server.CreateObject("adodb.recordset")
47 With rsTemp
      With rsTemp
48 .ActiveConnection = idbConn
         .ActiveConnection = idbConn
49 .CursorType = 1
         .CursorType = 1
50 .LockType = 1
         .LockType = 1
51 .Source ="select * from [" & TableName & "] where 1 = -1"
         .Source ="select * from [" & TableName & "] where 1 = -1"
52 .Open
         .Open
53 For i = 0 to Ubound(ValueList)
         For i = 0 to Ubound(ValueList)
54 CurrentField = Left(ValueList(i),Instr(ValueList(i),":")-1)
            CurrentField = Left(ValueList(i),Instr(ValueList(i),":")-1)
55 CurrentValue = Mid(ValueList(i),Instr(ValueList(i),":")+1)
            CurrentValue = Mid(ValueList(i),Instr(ValueList(i),":")+1)
56 If i <> 0 Then
            If i <> 0 Then
57 Select Case sType
               Select Case sType
58 Case 1
                  Case 1
59 StrTemp = StrTemp & " And "
                     StrTemp = StrTemp & " And "
60 Case Else
                  Case Else
61 StrTemp = StrTemp & ", "
                     StrTemp = StrTemp & ", "
62 End Select
               End Select
63 End If
            End If
64 If sType = 2 Then
            If sType = 2 Then
65 StrTemp = StrTemp & "[" & CurrentField & "]"
               StrTemp = StrTemp & "[" & CurrentField & "]"
66 Else
            Else
67 Select Case .Fields(CurrentField).Type
               Select Case .Fields(CurrentField).Type
68 Case 7,133,134,135,8,129,200,201,202,203
                  Case 7,133,134,135,8,129,200,201,202,203
69 If sType = 3 Then
                     If sType = 3 Then
70 StrTemp = StrTemp & "'"&CurrentValue&"'"
                        StrTemp = StrTemp & "'"&CurrentValue&"'"
71 Else
                     Else
72 StrTemp = StrTemp & "[" & CurrentField & "] = '"&CurrentValue&"'"
                        StrTemp = StrTemp & "[" & CurrentField & "] = '"&CurrentValue&"'"
73 End If
                     End If
74 Case 11
                  Case 11
75 If UCase(cstr(Trim(CurrentValue)))="TRUE" Then
                     If UCase(cstr(Trim(CurrentValue)))="TRUE" Then
76 If sType = 3 Then
                        If sType = 3 Then
77 StrTemp = StrTemp & "1"
                           StrTemp = StrTemp & "1"
78 Else
                        Else
79 StrTemp = StrTemp & "[" & CurrentField & "] = 1"
                           StrTemp = StrTemp & "[" & CurrentField & "] = 1"
80 End If
                        End If
81 Else
                     Else 
82 If sType = 3 Then
                        If sType = 3 Then
83 StrTemp = StrTemp & "0"
                           StrTemp = StrTemp & "0"
84 Else
                        Else
85 StrTemp = StrTemp & "[" & CurrentField & "] = 0"
                           StrTemp = StrTemp & "[" & CurrentField & "] = 0"
86 End If
                        End If
87 End If
                     End If
88 Case Else
                  Case Else
89 If sType = 3 Then
                     If sType = 3 Then
90 StrTemp = StrTemp & CurrentValue
                        StrTemp = StrTemp & CurrentValue
91 Else
                     Else
92 StrTemp = StrTemp & "[" & CurrentField & "] = " & CurrentValue
                        StrTemp = StrTemp & "[" & CurrentField & "] = " & CurrentValue
93 End If
                     End If
94 End Select
               End Select
95 End If
            End If
96 Next
         Next
97 End With
      End With
98 If Err.number <> 0 Then
      If Err.number <> 0 Then
99 idbErr = idbErr & "生成SQL语句出错!<br />"
         idbErr = idbErr & "生成SQL语句出错!<br />"
100 If debug Then idbErr = idbErr & "错误信息:"& Err.Description
         If debug Then idbErr = idbErr & "错误信息:"& Err.Description
101 rsTemp.close()
         rsTemp.close()
102 Set rsTemp = Nothing
         Set rsTemp = Nothing
103 Exit Function
         Exit Function
104 End If
      End If
105 rsTemp.Close()
      rsTemp.Close()
106 Set rsTemp = Nothing
      Set rsTemp = Nothing
107 End If
   End If
108 ValueToSql = StrTemp
   ValueToSql = StrTemp
109 End Function
End Function
110
111 Private Function DoExecute(ByVal sql)
Private Function DoExecute(ByVal sql)
112 Dim ExecuteCmd
   Dim ExecuteCmd
113 Set ExecuteCmd = Server.CreateObject("ADODB.Command")
   Set ExecuteCmd = Server.CreateObject("ADODB.Command")
114 With ExecuteCmd
   With ExecuteCmd
115 .ActiveConnection = idbConn
      .ActiveConnection = idbConn
116 .CommandText = sql
      .CommandText = sql
117 .Execute
      .Execute
118 End With
   End With
119 Set ExecuteCmd = Nothing
   Set ExecuteCmd = Nothing
120 End Function
End Function
121 End Class
End Class
122 %>
%>
 
 Public Function ReadTable(ByVal TableName,ByVal Condition,ByVal GetFieldNames)
Public Function ReadTable(ByVal TableName,ByVal Condition,ByVal GetFieldNames)2
 On Error Resume Next
   On Error Resume Next3
 Dim rstGetValue,Sql,BaseCondition,arrTemp,arrStr,TempStr,i
   Dim rstGetValue,Sql,BaseCondition,arrTemp,arrStr,TempStr,i4
 TempStr = "" : arrStr = ""
   TempStr = "" : arrStr = ""5
 '给出SQL条件语句
   '给出SQL条件语句6
 BaseCondition = ValueToSql(TableName,Condition,1)
   BaseCondition = ValueToSql(TableName,Condition,1)7
 '读取数据
'读取数据8
 Set rstGetValue = Server.CreateObject("ADODB.Recordset")
   Set rstGetValue = Server.CreateObject("ADODB.Recordset")9
 Sql = "Select "&GetFieldNames&" From ["&TableName&"] Where "&BaseCondition
   Sql = "Select "&GetFieldNames&" From ["&TableName&"] Where "&BaseCondition10
 rstGetValue.Open Sql,idbConn,1,1
   rstGetValue.Open Sql,idbConn,1,111
 If rstGetValue.RecordCount > 0 Then
   If rstGetValue.RecordCount > 0 Then12
 If Instr(GetFieldNames,",")>0 Then
      If Instr(GetFieldNames,",")>0 Then13
 arrTemp = Split(GetFieldNames,",")
         arrTemp = Split(GetFieldNames,",")14
 For i = 0 To Ubound(arrTemp)
         For i = 0 To Ubound(arrTemp)15
 If i<>0 Then arrStr = arrStr &Chr(112)&Chr(112)&Chr(113)
            If i<>0 Then arrStr = arrStr &Chr(112)&Chr(112)&Chr(113)16
 arrStr = arrStr & rstGetValue.Fields(i).Value
            arrStr = arrStr & rstGetValue.Fields(i).Value17
 Next
         Next18
 TempStr = Split(arrStr,Chr(112)&Chr(112)&Chr(113))
         TempStr = Split(arrStr,Chr(112)&Chr(112)&Chr(113))19
 Else
      Else20
 TempStr = rstGetValue.Fields(0).Value
         TempStr = rstGetValue.Fields(0).Value21
 End If
      End If22
 End If
   End If23
 If Err.number <> 0 Then
   If Err.number <> 0 Then24
 idbErr = idbErr & "获取数据出错!<br />"
      idbErr = idbErr & "获取数据出错!<br />"25
 If debug Then idbErr = idbErr & "错误信息:"& Err.Description
      If debug Then idbErr = idbErr & "错误信息:"& Err.Description26
 rstGetValue.close()
      rstGetValue.close()27
 Set rstGetValue = Nothing
      Set rstGetValue = Nothing28
 Exit Function
      Exit Function29
 End If
   End If30
 rstGetValue.close()
   rstGetValue.close()31
 Set rstGetValue = Nothing
   Set rstGetValue = Nothing32
 ReadTable = TempStr
   ReadTable = TempStr33
 End Function
End Function34

35
 Public Function C(ByVal ObjRs)
Public Function C(ByVal ObjRs)36
 ObjRs.close()
   ObjRs.close()37
 Set ObjRs = Nothing
   Set ObjRs = Nothing38
 End Function
End Function39

40
 Private Function ValueToSql(ByVal TableName, ByVal ValueList, ByVal sType)
Private Function ValueToSql(ByVal TableName, ByVal ValueList, ByVal sType)41
 Dim StrTemp
   Dim StrTemp42
 StrTemp = ValueList
   StrTemp = ValueList43
 If IsArray(ValueList) Then
   If IsArray(ValueList) Then44
 StrTemp = ""
      StrTemp = ""45
 Dim rsTemp, CurrentField, CurrentValue, i
      Dim rsTemp, CurrentField, CurrentValue, i46
 Set rsTemp = Server.CreateObject("adodb.recordset")
      Set rsTemp = Server.CreateObject("adodb.recordset")47
 With rsTemp
      With rsTemp48
 .ActiveConnection = idbConn
         .ActiveConnection = idbConn49
 .CursorType = 1
         .CursorType = 150
 .LockType = 1
         .LockType = 151
 .Source ="select * from [" & TableName & "] where 1 = -1"
         .Source ="select * from [" & TableName & "] where 1 = -1"52
 .Open
         .Open53
 For i = 0 to Ubound(ValueList)
         For i = 0 to Ubound(ValueList)54
 CurrentField = Left(ValueList(i),Instr(ValueList(i),":")-1)
            CurrentField = Left(ValueList(i),Instr(ValueList(i),":")-1)55
 CurrentValue = Mid(ValueList(i),Instr(ValueList(i),":")+1)
            CurrentValue = Mid(ValueList(i),Instr(ValueList(i),":")+1)56
 If i <> 0 Then
            If i <> 0 Then57
 Select Case sType
               Select Case sType58
 Case 1
                  Case 159
 StrTemp = StrTemp & " And "
                     StrTemp = StrTemp & " And "60
 Case Else
                  Case Else61
 StrTemp = StrTemp & ", "
                     StrTemp = StrTemp & ", "62
 End Select
               End Select63
 End If
            End If64
 If sType = 2 Then
            If sType = 2 Then65
 StrTemp = StrTemp & "[" & CurrentField & "]"
               StrTemp = StrTemp & "[" & CurrentField & "]"66
 Else
            Else67
 Select Case .Fields(CurrentField).Type
               Select Case .Fields(CurrentField).Type68
 Case 7,133,134,135,8,129,200,201,202,203
                  Case 7,133,134,135,8,129,200,201,202,20369
 If sType = 3 Then
                     If sType = 3 Then70
 StrTemp = StrTemp & "'"&CurrentValue&"'"
                        StrTemp = StrTemp & "'"&CurrentValue&"'"71
 Else
                     Else72
 StrTemp = StrTemp & "[" & CurrentField & "] = '"&CurrentValue&"'"
                        StrTemp = StrTemp & "[" & CurrentField & "] = '"&CurrentValue&"'"73
 End If
                     End If74
 Case 11
                  Case 1175
 If UCase(cstr(Trim(CurrentValue)))="TRUE" Then
                     If UCase(cstr(Trim(CurrentValue)))="TRUE" Then76
 If sType = 3 Then
                        If sType = 3 Then77
 StrTemp = StrTemp & "1"
                           StrTemp = StrTemp & "1"78
 Else
                        Else79
 StrTemp = StrTemp & "[" & CurrentField & "] = 1"
                           StrTemp = StrTemp & "[" & CurrentField & "] = 1"80
 End If
                        End If81
 Else
                     Else 82
 If sType = 3 Then
                        If sType = 3 Then83
 StrTemp = StrTemp & "0"
                           StrTemp = StrTemp & "0"84
 Else
                        Else85
 StrTemp = StrTemp & "[" & CurrentField & "] = 0"
                           StrTemp = StrTemp & "[" & CurrentField & "] = 0"86
 End If
                        End If87
 End If
                     End If88
 Case Else
                  Case Else89
 If sType = 3 Then
                     If sType = 3 Then90
 StrTemp = StrTemp & CurrentValue
                        StrTemp = StrTemp & CurrentValue91
 Else
                     Else92
 StrTemp = StrTemp & "[" & CurrentField & "] = " & CurrentValue
                        StrTemp = StrTemp & "[" & CurrentField & "] = " & CurrentValue93
 End If
                     End If94
 End Select
               End Select95
 End If
            End If96
 Next
         Next97
 End With
      End With98
 If Err.number <> 0 Then
      If Err.number <> 0 Then99
 idbErr = idbErr & "生成SQL语句出错!<br />"
         idbErr = idbErr & "生成SQL语句出错!<br />"100
 If debug Then idbErr = idbErr & "错误信息:"& Err.Description
         If debug Then idbErr = idbErr & "错误信息:"& Err.Description101
 rsTemp.close()
         rsTemp.close()102
 Set rsTemp = Nothing
         Set rsTemp = Nothing103
 Exit Function
         Exit Function104
 End If
      End If105
 rsTemp.Close()
      rsTemp.Close()106
 Set rsTemp = Nothing
      Set rsTemp = Nothing107
 End If
   End If108
 ValueToSql = StrTemp
   ValueToSql = StrTemp109
 End Function
End Function110

111
 Private Function DoExecute(ByVal sql)
Private Function DoExecute(ByVal sql)112
 Dim ExecuteCmd
   Dim ExecuteCmd113
 Set ExecuteCmd = Server.CreateObject("ADODB.Command")
   Set ExecuteCmd = Server.CreateObject("ADODB.Command")114
 With ExecuteCmd
   With ExecuteCmd115
 .ActiveConnection = idbConn
      .ActiveConnection = idbConn116
 .CommandText = sql
      .CommandText = sql117
 .Execute
      .Execute118
 End With
   End With119
 Set ExecuteCmd = Nothing
   Set ExecuteCmd = Nothing120
 End Function
End Function121
 End Class
End Class122
 %>
%> 
                    
                     
                    
                 
                    
                 
 
         
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号