steven-lwh 2007-7-16 17:12
请教个关于palm数据库编程的问题
如果想把一个文本域Filed的内容保存到数据库中应该如何操作?我像这样操作可以吗?DmWrite(RecordPointer, 0, "FldGetTextPtr(field)", 24);用FldGetTextPtr()返回的应该是什么?是文本的内容吗?
lyserver 2007-7-18 11:10
插入记录
//添加新记录
void newRecord( char *newRec,char *scanDate)
{
UInt16 index;
VoidPtr newRecords;
MemHandle newRecordH;
VoidPtr *newRecordP;
Int16 RecCount=0;
//UInt16 i=0;
/*RecCount=DmNumRecords(gDB);//记录数量
for(i=0;i<RecCount;++i)
{
MemHandle RecordH=DmQueryRecord(gDB,i);//查找适合插入记录的位置
VoidPtr *RecordP=MemHandleLock(RecordH);
MemHandleUnlock(RecordH);
FrmCustomAlert (GeneralAlert, RecordP->rec, NULL, NULL);
}*/
strcpy(newRecords.rec,newRec);
strcpy(newRecords.scandate,scanDate);
index = DmFindSortPosition(gDB,&newRecords,NULL,(DmComparF *)MyCompareFunc,NULL);//找到合适记录插入点
newRecordH=DmNewRecord(gDB,&index,sizeof(newRecords)); //创建新记录
newRecordP=MemHandleLock(newRecordH); //锁定刚刚申请的记录内存空间
DmWrite(newRecordP,0,&newRecords,sizeof(newRecords)); //写入到记录中
MemHandleUnlock(newRecordH); //记录解锁
DmReleaseRecord(gDB,index,true); //真正保存到库中
RecCount=DmNumRecords(gDB);//记录数量
sprintf(msg, "保存完毕!记录数: %i", RecCount);
SetFieldText (MainStatusField, msg, 39, true);//显示到状态lable中
return;
}