home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / Query_Buio390741232001.psc / InsertQuery.cls < prev    next >
Encoding:
Visual Basic class definition  |  2001-12-06  |  2.8 KB  |  84 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "InsertQuery"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = False
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = True
  14. Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
  15. Attribute VB_Ext_KEY = "Member0" ,"Fields"
  16. Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
  17. '==============================================================
  18. 'Class          InsertQuery
  19. 'Description    Insert Query main
  20. '==============================================================
  21. Option Explicit
  22.  
  23. '____________________________
  24. 'Private members
  25. Private oFields As EasyQDll.Fields
  26. Private sDomain As String
  27.  
  28. '=============================================================
  29. 'Initialise and terminate events
  30. '=============================================================
  31. Private Sub Class_Initialize()
  32.     Set oFields = New EasyQDll.Fields
  33. End Sub
  34. Private Sub Class_Terminate()
  35.     If Not oFields Is Nothing Then Set oFields = Nothing
  36. End Sub
  37.  
  38. '=============================================================
  39. 'Return a reference to the fields object
  40. '=============================================================
  41. Public Property Get Fields() As EasyQDll.Fields
  42.     Set Fields = oFields
  43. End Property
  44.  
  45. '=============================================================
  46. 'The domain for insert
  47. '=============================================================
  48. Public Property Let pDomain(sNewValue As String)
  49.     sDomain = sNewValue
  50. End Property
  51.  
  52. '=============================================================
  53. 'Return the string
  54. '=============================================================
  55. Public Property Get pGenSQL() As String
  56. Dim oField As EasyQDll.Field
  57. Dim sNames As String
  58. Dim sValues As String
  59.  
  60.     '__________________________________
  61.     'If not domain has been selected then exit
  62.     If sDomain = "" Then Exit Property
  63.     sNames = ""
  64.     sValues = ""
  65.     
  66.     '___________________________________
  67.     'Build the field string for the sql
  68.     For Each oField In oFields
  69.         sNames = sNames & oField.Name & ","
  70.         If oField.DataType = "" Or UCase(oField.DataType) = "STRING" _
  71.         Or UCase(oField.DataType) = "DATE" Then
  72.             sValues = sValues & "'" & oField.Value & "',"
  73.         Else
  74.             sValues = sValues & oField.Value & ","
  75.         End If
  76.     Next oField
  77.     
  78.     '____________________________________
  79.     'Build the sql string
  80.     pGenSQL = "INSERT INTO " & sDomain & " (" & Left(sNames, Len(sNames) - 1) & ") VALUES (" & Left(sValues, Len(sValues) - 1) & ")"
  81.     oFields.Clear
  82.     
  83. End Property
  84.