The index number in the schedule control was never intended to be used to generate unique identity-type IDs for each schedule item. As you point out, it is only a sequence number for the schedule items currently in the schedule control. You will need to write your own routine to generate unique IDs for the schedule item records in your database.
Once you have done that, the Name property on each schedule item lets you store the database ID with each schedule item and can be used to find schedule item by your database ID. The Name property happens to be a string type property, which is why you may have to convert you database ID to a string, but you can still use it as follows:
When you add an existing schedule record to the schedule control:
// Assuming "schedule_id" is the field containing your database ID and it is numeric -
ls_key = String(ids_schedule.GetItemNumber(ll_row, "schedule_id") )
ldt_start = ids_schedule.GetItemDateTime(ll_row, "start_dt")
ll_length = <length of appointment in minutes>
ls_display = <description to display on the schedule item>
// The following are optional depending on whether you want to show resources
// or categories in the schedule.
ls_resource = ""
ls_category = ""
// Add the schedule item.
ole_schedule.Object.ScheduleItems.Add(ls_key, ldt_start, ls_resource, ldt_start, ll_length, ls_display, ls_category)
To add your database ID to a newly created schedule item:
// Where loo_item is the OLEObject containing the new schedule item
// and ll_id is your new database ID:
loo_item.Name = String(ll_id)
To find a schedule item using your database ID:
OLEObject loo_item
String ls_key
// Where ll_id is your database ID
ls_key = String(ll_id)
loo_item = ole_schedule.Object.ScheduleItems.Item(ls_key)
To get your database ID from a known schedule item:
String ls_key
Long ll_id
ls_key = loo_item.Name
ll_id = Long(ls_key)
To get your database ID from a schedule control index number:
String ls_key
Long ll_id
// Where li_index is the schedule control index number
ls_key = ole_schedule.Object.ScheduleItems[li_index].Name
ll_id = Long(ls_key)
For more details look for the ScheduleItems Name property and the Item( ) method for ScheduleItems in the GravityBox help.