Public Sub Save()
Dim strSQL As String
Dim guid As CGuid
Dim bInsert As Boolean
If ID = "" Then
' Generate the ID
bInsert = True
Set guid = New CGuid
ID = guid.GetGuid
Else
bInsert = False
End If
If bInsert Then
strSQL = "INSERT INTO tblPerson " & _
"(ID, FirstName, LastName, XMLData) " & _
"VALUES ('" & ID & "', '" & FirstName & _
"', '" & LastName & "', '" & FormatXML() _
& "')"
Else
' Update
strSQL = "UPDATE tblPerson " & _
"SET FirstName = '" & FirstName & _
"', " & "LastName = '" & LastName & _
"', " & "XMLData = '" & FormatXML() & _
"' WHERE ID = '" & ID & "'"
End If
mcn.Open
mcn.Execute strSQL
mcn.Close
Set mcn = Nothing
End Sub
|