Print Page | Close Window

Copy/Clone an Event

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Calendar
Forum Description: Topics Related to Codejock Calendar
URL: http://forum.codejock.com/forum_posts.asp?TID=11695
Printed Date: 07 October 2024 at 7:22am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Copy/Clone an Event
Posted By: mkhadem
Subject: Copy/Clone an Event
Date Posted: 01 August 2008 at 12:28pm
Hi,
I have issue to clone an event without setting the event id.
If I use CloneEvent or set my new event to the one which I want to copy it copies the eventID too and I can not save it as a new event and get the DB error:
Cannot CreateEvent in DB: ORA-00001: unique constraint (SYSTEM.PK_CALENDAR_EVENTS) violated
 
Dim CopiedEvent As CalendarEvent
 
' Here I want to keep the new created EventId
Set CopiedEvent = CalendarControl.DataProvider.CreateEvent
 
'Here the new event id is changed to the original event id
Set CopiedEvent = OriginalEvent.CloneEvent
 
Any clue?
 
Thanks
Mo



Replies:
Posted By: Oleg
Date Posted: 06 August 2008 at 4:31am
Hello,
 
What DataProvider do you use? I tried with our sample use Access mdb file and added this code:
 
 Dim Ev As CalendarEvent, E As CalendarEvent
    Set Ev = CalendarControl.DataProvider.GetEvent(1)
   
    Set E = Ev.CloneEvent()
   
    CalendarControl.DataProvider.AddEvent E
Works fine - DataProvider automatically generated new EventId in AddEvent  method.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: mkhadem
Date Posted: 08 August 2008 at 2:43pm

Hi,

I am using ORACLE and the event ID is not set automatically. I use oracle sequence to get the next valid ID.
 
Here is the workaround but I don't like it. I have to set all event parameters manually to be able to assign my new event ID.
Do you have a better solution?
 
Regards
Mo
 
' Get new ID
 nEventID = m_pDB.DoGetNextUniqueID
 
' Set my event
Set pEvent = m_pCalendar.DataProvider.CreateEventEx(nEventID)
 
pEvent.MeetingFlag = IIf(pEventRS("IsMeeting") <> 0, True, False)
pEvent.PrivateFlag = IIf(pEventRS("IsPrivate") <> 0, True, False)
pEvent.Label = pEventRS("LabelID")
 
and so on...


Posted By: mkhadem
Date Posted: 12 August 2008 at 4:34pm
Thanks oleg,
I did it as you said and just assigned my EventId in the Sub for DoCreateEvent.
 
Thanks for your help.
Mo



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net