Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Calendar
  New Posts New Posts RSS Feed - Multiple Resources
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Multiple Resources

 Post Reply Post Reply
Author
Message
tslu View Drop Down
Newbie
Newbie


Joined: 14 September 2006
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote tslu Quote  Post ReplyReply Direct Link To This Post Topic: Multiple Resources
    Posted: 14 September 2006 at 5:35am
How can I improve the following. I am new to this. I'm quit confused

   pSchedules.AddNewSchedule rsStaff.Fields("Name").Value
   pRes0.Name = rsStaff.Fields("Name").Value
   pRes0.ScheduleIDs.Add rsStaff.Fields("ID").Value
   arResources.Add pRes0
   rsStaff.MoveNext
   
   Do While Not rsStaff.EOF
       I = I + 1
       pSchedules.AddNewSchedule rsStaff.Fields("Name").Value
       Set pRes1 = New CalendarResource
       pRes1.SetDataProvider pRes0.DataProvider, False
       pRes1.Name = rsStaff.Fields("Name").Value
       pRes1.ScheduleIDs.Add I
       arResources.Add pRes1
      rsStaff.MoveNext
   Loop
Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post Posted: 14 September 2006 at 4:34pm
And what exactly do you want to improve? What's your problem?
 
--
WBR,
Serge
Back to Top
tslu View Drop Down
Newbie
Newbie


Joined: 14 September 2006
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote tslu Quote  Post ReplyReply Direct Link To This Post Posted: 14 September 2006 at 8:21pm
 The code below works:
 
   pSchedules.AddNewSchedule rsStaff.Fields("Name").Value
   pRes0.Name = rsStaff.Fields("Name").Value
   pRes0.ScheduleIDs.Add rsStaff.Fields("ID").Value
   arResources.Add pRes0
   rsStaff.MoveNext
   
   Do While Not rsStaff.EOF
       I = I + 1
       pSchedules.AddNewSchedule rsStaff.Fields("Name").Value
       Set pRes1 = New CalendarResource
       pRes1.SetDataProvider pRes0.DataProvider, False
       pRes1.Name = rsStaff.Fields("Name").Value
       pRes1.ScheduleIDs.Add I
       arResources.Add pRes1
      rsStaff.MoveNext
   Loop

if I dont want include the part before the do...while loop it doesnt work as it doesnt show what I have in the Event.mdb.
Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post Posted: 21 September 2006 at 8:26am
Hi,

I do not think that this is a real problem.
Just a cooding style.
 
The code before
    do...while
need to create a data provider in first resource and use it for all others.
 
But you can easily rewrite this code.
 
for example:
-----------------------------------------------------------------
   Dim pDataProvider as CalendarDataProvider
 
   Do While Not rsStaff.EOF
       I = I + 1
 
       pSchedules.AddNewSchedule rsStaff.Fields("Name").Value
       Set pRes1 = New CalendarResource
               
       if I == 1 then
            pRes1.SetDataProvider2 "connection string", True
            set pDataProvider = pRes1.DataProvider
       else
           pRes1.SetDataProvider pDataProvider, False
       endif
 
       pRes1.Name = rsStaff.Fields("Name").Value
       pRes1.ScheduleIDs.Add I
       arResources.Add pRes1
      rsStaff.MoveNext
   Loop

 
Also to free memory correctly, you have to set bCloseDataProviderWhenDestroy = True for one resource.

--
WBR,
Serge
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.188 seconds.