现在需要要cedb数据库
可是写操作CeWriteRecordProps总是不成功,返回值为0,用GetLastError得到的说是参数问题 我看过以前的帖子,因为我用的是模拟器,他说如果是模拟器 打开与pc的共享就会出现这个问题 这个是什么意思 是在哪里设置的呢?
非常着急,望高手解答。
我的email :jiangshen_@126.com
pBuff=0;
if(!(CeOid=CeCreateDatabase(szNewDBName,dwNewDBType,0,NULL)))
{
temp=NULL;
temp=(TCHAR*)LocalAlloc(LMEM_FIXED,50*sizeof(TCHAR));
_tcscpy(temp,TEXT("create error"));
DrawText(hdc, temp, _tcslen(temp), &rt, DT_CENTER);
//error
}
else
{
//temp=NULL;
//temp=(TCHAR*)LocalAlloc(LMEM_FIXED,50*sizeof(TCHAR));
//_tcscpy(temp,TEXT("create ok"));
//DrawText(hdc, temp, _tcslen(temp), &rt, DT_CENTER);
HANDLE hNewDB;
LPWSTR lpStr;
//open DB
hNewDB=CeOpenDatabase(&CeOid,NULL,0,0,NULL);
if(hNewDB==INVALID_HANDLE_VALUE)
{
temp=NULL;
temp=(TCHAR*)LocalAlloc(LMEM_FIXED,50*sizeof(TCHAR));
_tcscpy(temp,TEXT("open error"));
DrawText(hdc, temp, _tcslen(temp), &rt, DT_CENTER);
//error handing
}
else
{
// temp=NULL;
//temp=(TCHAR*)LocalAlloc(LMEM_FIXED,50*sizeof(TCHAR));
//_tcscpy(temp,TEXT("open ok"));
//DrawText(hdc, temp, _tcslen(temp), &rt, DT_CENTER);
CEPROPVAL NewRecProps[1];
CEOID poidRecord;
//lpStr=(TCHAR*)LocalAlloc(LMEM_FIXED,50*sizeof(TCHAR));
// _tcscpy(lpStr,TEXT("shanghai beijing"));
NewRecProps[0].propid=PID_NAME;
NewRecProps[0].wLenData=0;
NewRecProps[0].wFlags=0;
NewRecProps[0].val.lpwstr=L"777rewr";
/*if((NewRecProps[0].val.lpwstr)!=NULL)
{
readout=NewRecProps[0].val.lpwstr;
temp=NULL;
DrawText(hdc, readout, _tcslen(readout), &rt, DT_CENTER);
}*/
////////////////////////////////////////////write
if(!(CeOid=CeWriteRecordProps(hNewDB,0,1,NewRecProps)))
{
if(ERROR_INVALID_PARAMETER==GetLastError())
{
temp=NULL;
temp=(TCHAR*)LocalAlloc(LMEM_FIXED,50*sizeof(TCHAR));
_tcscpy(temp,TEXT("write error pramter"));
DrawText(hdc, temp, _tcslen(temp), &rt, DT_CENTER);
}
}
//////////////////////////////////////////////////////////////////find
CEPROPVAL Property;
Property.propid=PID_NAME;
Property.wLenData=0;
Property.wFlags=0;
Property.val.lpwstr=lpStr;
poidRecord=CeSeekDatabase(hNewDB,CEDB_SEEK_BEGINNING,0,&dwlndex);
poidRecord=CeSeekDatabase(hNewDB,CEDB_SEEK_VALUEFIRSTEQUAL,(DWORD)&Property,&dwlndex);
//////////////////////////////////////////////////read
CeReadRecordProps(hNewDB,CEDB_ALLOWREALLOC,&wProps,NULL,&(LPBYTE)pBuff,&dwRecSize);
pRecord=(PCEPROPVAL)pBuff;
readout=NULL;
lstrcpy(readout,pRecord->val.lpwstr);
/*if(readout!=NULL)
{
temp=NULL;
temp=(TCHAR*)LocalAlloc(LMEM_FIXED,50*sizeof(TCHAR));
_tcscpy(temp,TEXT("read ok"));
DrawText(hdc, temp, _tcslen(temp), &rt, DT_CENTER);
}*/
}
}