<% Class sqlstring '********************************** The variable definition' ***** *************************************** ATABLENAME ---- Table name 'isqltype ---- SQL Statement Type: 0 - Increase, 1-update, 2-Delete, 3-Query 'Swhere ---- Condition' Sorder ---- Sort Mode 'SSQL ---- Value
Private Stablename, Isqltype, Swhere, Sorder, SSQL
'********************************** The initialization / end' ****** ****************************
Private sub coplass_initialize () stablename = "" isqltype = 0swhere = "" sorder = "" ssql = "" End Sub
Private sub coplass_terminate ()
End Sub
'************************************'Attributes'********** ************************* The property publiC Property Let Where (Value) StableName = ValueEnd Property Set Condition Public Property Let Where (Value) Swhere = valueEnd Property 'Set Sort Mode PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC Property Let Order (Value) Sorder = ValueEnd Property' Set the type of query statement
Public property let sqltype (value) isqltype = valueselect case isqltypecase 0ssql = "INSERT INTO {& * #} 0 ({& * #} 1) VALUES ({& * #} 2)" Case 1ssql = "Update {& * # } 0 set {& * #} 1 = {& * #} 2 "Case 2ssql =" Delete from {& * #} 0 "Case 3ssql =" SELECT {& * #} 1 from {& * #} 0 "End Selectnd Property
'************************************'function'********** ************************* Add field (field name, field value)
Public Sub Addfield (SfieldName, Svalue) Select Case Isqltypecase 0ssql = Replace (SSQL, "{& * #} 1", SfieldName & ", {& * #} 1") SSQL = Replace (SSQL, "{& * #} 2 "," & Svalue & ", {& * #} 2") Case 1ssql = Replace (SSQL, "{& * #} 1", sfieldname) SSQL = Replace (SSQL, "{& * #} 2" , "& Svalue &", {& * #} 1 = {& * #} 2 ") Case 3ssql = Replace (SSQL," {& * #} 1 ", SfieldName &", {& * #} 1 " ) End selectenD Sub 'Function "Returns SQL Statement PUBLIC FUNCTION RETURnsql () SSQL = Replace (SSQL," {& * #} 0 ", StableName) Select Case Isqltype Case 0 SSQL = Replace (SSQL, ", {& * #} 1", "") SSQL = Replace (SSQL, ", {& * #} 2", "") Case 1 SSQL = Replace (SSQL, ", = {& * #} 1 = { & * #} 2 "," ") Case 3 SSQL = Replace (SSQL,", {& * #} 1 "," ") End Select if Swhere <>" "and isqltype <> 0 THEN SSQL = SSQL &" WHERE "& SWHERE END IF Ender <>" "and isqltype <> 0 THEN SSQL = SSQL &" Order By "& Sorder End Function
'Return to SQL Statement Public Function Returnsql1 () SSQL = Replace (SSQL, "{& * #} 0", Stablename) Select Case ISQLTYPECASE 0SSQL = Replace (SSQL, ", {& * #} 1", "") SSQL = Replace (SSQL, ", {& * #} 2", "") case 1ssql = replace (ssql, ", = {& * #} 2", "") Case 3ssql = Replace (SSQL , ", {& * #} 1", "") End selectif swhere <> "" and isqltype <> 0 Thenssql = SSQL & "Where" & SwhereEnd IFIF SORDER <> "" and isqltype <> 0 Thenssql = SSQL & "Order by" & sorderend ifreturnsql = ssqlend function "Clear statement
Public Sub Clear () Stablename = "" isqltype = 0swhere = "" sorder = "" ssql = "" End Subend Class%>