Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
End Users
Pocket PCActiveSyncMultimediaEBooksWirelessSmartPhones
Developers
Windows MobileSmartPhonesWinCE ProgrammingVB for WinCEVC++ for WinCEPlatform BuilderTest Tools
PocketPC DirectoryFree SoftwareWeb Resources
Related Topics
PalmMobile PhonesMore Topics ...

Pocket PC Forum / Developers / SmartPhones / January 2008

Tip: Looking for answers? Try searching our database.

EDB database error in creation

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
akshay1384@gmail.com - 16 Jan 2008 07:04 GMT
hi all

I am working on an EDB database using windows mobile 6 sdk.On calling
the CeCreateDatabaseWithProps function, i am getting INVALID PARAMETER
ERROR.This is the code that i am using to mount and create the
database.

const CEPROPID propCompany = MAKELONG(CEVT_LPWSTR, 100);

const CEPROPID propCompanyID = MAKELONG(CEVT_I4, 101);

const CEPROPID propCompanyEmp = MAKELONG(CEVT_LPWSTR, 102);

CEDBASEINFOEX DBInfo;

BOOL bRtn = TRUE;

CEOID DBOid=0 ;

Fill in the DBInfo structure

CREATE_SYSTEMGUID(&m_VolGUID);

memset(&DBInfo, 0, sizeof(CEDBASEINFOEX)) ;

DBInfo.wVersion = CEDBASEINFOEX_VERSION;

DBInfo.dwFlags = CEDB_VALIDNAME | CEDB_VALIDTYPE | CEDB_VALIDDBFLAGS;

DBInfo.wNumSortOrder = 3;

DBInfo.rgSortSpecs[0].wVersion = SORTORDERSPECEX_VERSION;

DBInfo.rgSortSpecs[0].wNumProps = 1;

DBInfo.rgSortSpecs[0].wKeyFlags = 0;

DBInfo.rgSortSpecs[0].rgPropID[0] = propCompany;

//DBInfo.rgSortSpecs[0].rgdwFlags[0] = CEDB_SORT_UNKNOWNFIRST;

DBInfo.rgSortSpecs[1].wVersion = SORTORDERSPECEX_VERSION;

DBInfo.rgSortSpecs[1].wNumProps = 1;

DBInfo.rgSortSpecs[1].wKeyFlags = 0;

DBInfo.rgSortSpecs[1].rgPropID[0] = propCompanyID;

//DBInfo.rgSortSpecs[1].rgdwFlags[0] = CEDB_SORT_UNKNOWNFIRST;

DBInfo.rgSortSpecs[2].wVersion = SORTORDERSPECEX_VERSION;

DBInfo.rgSortSpecs[2].wNumProps = 1;

DBInfo.rgSortSpecs[2].wKeyFlags = 0;

DBInfo.rgSortSpecs[2].rgPropID[0] = propCompanyEmp;

//DBInfo.rgSortSpecs[2].rgdwFlags[0] = CEDB_SORT_UNKNOWNFIRST;

StringCchCopy(DBInfo.szDbaseName, ARRAYSIZE(DBInfo.szDbaseName),
tszDBName);

// Volume might exist, create anyway

#ifdef EDB

if (!CeMountDBVolEx( &m_VolGUID, pszDBVolName,NULL, CREATE_ALWAYS ))

#else

if (!CeMountDBVol( &m_VolGUID, pszDBVolName, CREATE_ALWAYS))

#endif // EDB

{

if (ERROR_INVALID_PARAMETER == GetLastError())

{

MessageBox(NULL,TEXT("Invalid Parameters -
CeMountDBVolEx"),TEXT("ERROR"),NULL);

}

else

{

MessageBox(NULL,TEXT("Application Mounted"),TEXT("REPORT"),NULL);

}

// Create the database

#ifdef EDB

if(NULL == (DBOid = CeCreateDatabaseWithProps(&m_VolGUID, &DBInfo, 0,
NULL)))

#else

if(NULL == (DBOid = CeCreateDatabaseEx2(&m_VolGUID, &DBInfo)))

#endif

{

// DB exists

if (ERROR_DUP_NAME == GetLastError())

{

MessageBox(NULL,TEXT("Name Already exists"),TEXT("ERROR"),NULL);

}

else if (ERROR_INVALID_PARAMETER == GetLastError())

{

MessageBox(NULL,TEXT("Invalid Parameters -
CeCreateDatabaseWithProps"),TEXT("ERROR"),NULL);

}

else

{

MessageBox(NULL,TEXT("Failed to create the
database"),TEXT("ERROR"),NULL);

}

goto Cleanup;

bRtn = FALSE;

}

I took the help of the sample application given inside the windows 6
sdk i.e FileDB, but that sample is also not according to what i want
to prepare.

Could any one please help on this matter?

Thanks in advance
Akshay
Drew Linerud [MSFT] - 18 Jan 2008 22:54 GMT
The problem may be with the following line:

DBInfo.wVersion = CEDBASEINFOEX_VERSION;

For an EDB database, this value needs to be 2, however,
CEDBASEINFOEX_VERSION can be defined as 1 or 2 depending on how header files
are included.

To ensure that CEDBASEINFOEX_VERSION is set correctly (and that other
database declarations/definitions are correct), you can either #define EDB
before including any header files (including windows.h), or #include
windbase_edb.h instead of windbase.h.

I hope that resolves your problem.

Drew
Signature

Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.

This posting is provided "AS IS" with no warranties, and confers no rights.

> hi all
>
[quoted text clipped - 148 lines]
> Thanks in advance
> Akshay
akshay1384@gmail.com - 21 Jan 2008 06:33 GMT
On Jan 19, 3:54 am, Drew Linerud [MSFT] <dre...@online.microsoft.com>
wrote:
> The problem may be with the following line:
>
[quoted text clipped - 173 lines]
>
> - Show quoted text -

Hi Drew

I checked the value of  DBInfo.wVersion = CEDBASEINFOEX_VERSION;
It is 2 only and i also used the same steps that u suggested. But
still the error remains i.e. "invalid parameters".
Is there any other step that i have forgotten here?
Please Advise,
Thanks
Akshay
Drew Linerud [MSFT] - 26 Jan 2008 00:00 GMT
Looking a little more closely, I notice that there was a problem with my
original post.  Windbase_edb.h cannot be used in place of windbase.h.  
Windbase_edb.h is actually included _by_ windbase.h when EDB is defined.  So
just be sure to #define EDB before including windows.h.

It doesn't seem like that's the problem you're having.  It doesn't seem that
you're missing any steps either, as I was able to compile and run your code
and have it succeed.  I only did a few things that weren't in the code you
posted.  First, I supplied the database volume name string and the database
name string.  It seems that the database volume name string didn't cause any
problem for you, so I would suggest to verify that the database name string
(copied into DBInfo.szDbaseName) is correct.  This should be a WCHAR string
and cannot be empty or contain only whitespace.  Also, verify that the string
copy is successful.

The second thing I did was to declare a local CEGUID (in place of
m_VolGUID).  I wouldn't expect this to make a difference.

Note also that you can get ERROR_INVALID_PARAMETER if the internal call to
CeAddDatabaseProps fails - even with a different error.  You can check out
the documentation on that function for more ideas of what may have gone wrong
here:

http://msdn2.microsoft.com/en-us/library/aa912124.aspx

Drew

Signature

Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.

This posting is provided "AS IS" with no warranties, and confers no rights.

> On Jan 19, 3:54 am, Drew Linerud [MSFT] <dre...@online.microsoft.com>
> wrote:
[quoted text clipped - 185 lines]
> Thanks
> Akshay
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.