> hi all,
> 
This is a conduit question but since I did not get enough responses, I am
posting my question here. Thanks for any help.

Here is the question :
> Has anyone tried to assign a Category Id to a record which creating it? I
> am writing a conduit to interface with the Datebook DB and I need to
> distinguish the records I create from the records that are already there.
> 
> I am trying to assign a number to the Category ID while creating the
> record. But when I read the records using SyncReadRecordByIndex, I have a
> weird situation where it creates as many records as I put in with the
> deleted and dirty bit set in them. I cannot see those records in the
> Datebook but I can see them through Insider( an application that lets you
> view all the records in all the Databases on the Pilot) and when I try to
> delete those "junk" records, the system crashes and I need to do a hard
> reset.
> 
The problem of "junk records" does not occur too often. Another problem that
happens consistently is that no matter what, I cannot assign a category Id
to Record 0. It does not give me any error but at the same time it does not
save the Category Id information in the record either.

> I want to know if I can assign a number to the Category Id in the first
> place. If so, am I doing this right? I am assigning a number 9 to the
> Category Id.  
> 
> Thanks for any help
> Kavitha
> 
> Here is my code  for your reference :
> 
> 
>       if((err =
> SyncOpenDB("DatebookDB",0,rHand,eDbRead|eDbWrite|eDbShowSecret)) != 0)
>       {
>               if(err == SYNCERR_NOT_FOUND)
>                       return -1;
> 
>               else
>               {
>                       sprintf(m_szLogMessage,"1003 - Error opening
> Datebook Database");
>                       LogAddEntry(m_szLogMessage,slWarning,false);
>                       return -1;
>               }
>       }
>       else
>       {
>               if((err = SyncGetDBRecordCount(rHand,numRecs)) != 0)
>               {
>                       sprintf(m_szLogMessage,"1004 - Error getting record
> count from DatebookDB");
>                       LogAddEntry(m_szLogMessage,slWarning,false);
>                       return -1;
>               }
> 
>               if(nrecNum > 0)
>                       numRecs = nrecNum;
> 
>               datebkRec.m_FileHandle = rHand;
>               datebkRec.m_RecId = (long) numRecs;
>               datebkRec.m_Attribs = 0;
>               datebkRec.m_CatId = 9;
>               datebkRec.m_dwReserved = 0;
>               datebkRec.m_TotalBytes = (unsigned short) sizeof(m_szBuff);
>               datebkRec.m_pBytes = (unsigned char*) malloc(MAX_RECORD_SIZE
> * sizeof(char));
>               datebkRec.m_RecSize = 0;
> 
>               pBuff = (char*) datebkRec.m_pBytes;
>               startTime.hours = (unsigned char)nstartTime;
>               startTime.minutes = 0;
>               
>               //Start Time
>               wTemp = (startTime.hours << HOUR_SHIFT_FACTOR) |
> startTime.minutes; 
>               wTemp = FlipWord(wTemp);
>               *((WORD *)pBuff) = wTemp;
>               pBuff += sizeof(WORD);
>               datebkRec.m_RecSize += sizeof(WORD);
> 
>               //Event Date
>               myDate.year = 99 - 4;
>               myDate.month = 8;
>               myDate.day = 25;
> 
>               wTemp =0; 
>               wTemp = (myDate.year << YEAR_SHIFT_FACTOR) | 
>                               (myDate.month << MONTH_SHIFT_FACTOR) |
> myDate.day;
>               wTemp = FlipWord(wTemp);
>               *((WORD *)(pBuff + sizeof(WORD))) = wTemp;
> 
>               //End Time
>               endTime.hours = (unsigned char)nendTime;
>               endTime.minutes = 0;
> 
>               wTemp =0; 
>               wTemp = (endTime.hours << HOUR_SHIFT_FACTOR) |
> endTime.minutes;
>               wTemp = FlipWord(wTemp);
>               *((WORD *)pBuff) = wTemp;
>               pBuff += sizeof(WORD) * 2;
>               datebkRec.m_RecSize += sizeof(WORD) * 2;
> 
>               //Flags
>               pFlags = pBuff;
>               *(unsigned char *)&flags = 0;
>               pBuff += sizeof(WORD);
>               datebkRec.m_RecSize += sizeof(WORD);
> 
>               //flags.alarm = 0;
>               //flags.repeat = 0;
>               //flags.exception = 0;
>               flags.description = 1;
> 
>               //Set Description
>               strcpy(srcStr,szDesc);
>               for(int i =0;i <strlen(srcStr);i++)
>               {
>                       *pBuff = srcStr[i];
>                       *pBuff++;
>               }
>               *pBuff = 0;
> 
>               pBuff ++;
>               datebkRec.m_RecSize += strlen(srcStr) + 1;
> 
>               //Note
>               flags.note = 1;
>               strcpy(srcStr,szNote);
>               for(i =0;i <strlen(srcStr);i++)
>               {
>                       *pBuff = srcStr[i];
>                       *pBuff++;
>               }
>               *pBuff = 0;
> 
>               pBuff ++;
>               datebkRec.m_RecSize += strlen(srcStr) + 1;
> 
>               *((BYTE *)pFlags) = *(BYTE *)&flags;
> 
>               if((err = SyncWriteRec(datebkRec)) != 0)
>               {
>                       sprintf(m_szLogMessage,"1005 - Error writing
> Datebook record");
>                       LogAddEntry(m_szLogMessage,slWarning,false);
>                       return 0;
>               }
>               AfxMessageBox("Record Written!!!");             
>       }
> 
>       SyncCloseDB(rHand);
> 
> --------------------------------------------------------------------------
> --------------
> Kavitha Tumkur                                        
> Noblestar Systems                                                     
> Mobile Computing Practice
> [EMAIL PROTECTED]
> 703-464-4000, Ext-3020
> 
> 

Reply via email to