Multiple Resources |
Post Reply |
Author | |
tslu
Newbie Joined: 14 September 2006 Status: Offline Points: 8 |
Post Options
Thanks(0)
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 |
|
sserge
Moderator Group Joined: 01 December 2004 Status: Offline Points: 1297 |
Post Options
Thanks(0)
|
And what exactly do you want to improve? What's your problem?
--
WBR,
Serge
|
|
tslu
Newbie Joined: 14 September 2006 Status: Offline Points: 8 |
Post Options
Thanks(0)
|
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. |
|
sserge
Moderator Group Joined: 01 December 2004 Status: Offline Points: 1297 |
Post Options
Thanks(0)
|
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 |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |