Solved

Connecting to a database

Posted on 2002-03-27
12
382 Views
Last Modified: 2007-11-27
How do I connect to a database(.mdb) through Windows CE programming??

I tried with CeOpenDatabase
and CCeDBDatabase cdb; cdb.Open(...)
I am not able to connect to the exixting database.

Any hints or points regarding this will be helpful.
0
Comment
Question by:pratimag
  • 4
  • 3
  • 3
  • +2
12 Comments
 
LVL 17

Expert Comment

by:mikecr
ID: 6903171
What program are you trying to open it with? If it's not Access, you need to have some type of ODBC driver installed to access the database.
0
 
LVL 44

Expert Comment

by:CrazyOne
ID: 6904421
Don't know that much about CE and its DB components and the Language you are using however most of the times you need to create the object you are going to use before you can have access to it. In this case I am not talking about the actual database .mdb file but the Database object in your code.

Something to the affect of.
CreateObject.DBComponent.

I have no idea of the actual syntax but you should be able to find reference to it somewhere.
0
 
LVL 44

Expert Comment

by:CrazyOne
ID: 6904433
Here you go From the MSDN Library

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceobjst/htm/cerefcecreatedatabase.asp


BEGIN ARTICLE

Microsoft Windows CE .NET  

CeCreateDatabase
This function creates a new database. This function is obsolete. Applications should call CeCreateDatabaseEx2 instead.

A RAPI version of this function exists, and it is also named CeCreateDatabaseEx (RAPI).

CEOID CeCreateDatabase(
LPWSTR lpszName,
DWORD dwDbaseType,
WORD wNumSortOrder,
SORTORDERSPEC *rgSortSpecs
);
Parameters
lpszName
[in] Long pointer to a null-terminated string that specifies the name for the new database. The name can have up to 32 characters, including the terminating null character. If the name is too long, it is truncated and the database is created. Do not use an empty string as the database name.
dwDbaseType
[in] Specifies the type identifier for the database. This is an application-defined value that can be used for any application-defined purpose. For example, an application can use the type identifier to distinguish address book data from to-do list data or use the identifier during a database enumeration sequence. For more information, see CeFindFirstDatabase. The type identifier is not meant to be a unique identifier for the database. The system does not use this value.
wNumSortOrder
[in] Number of sort orders active in the database, with four being the maximum number. This parameter can be zero if no sort orders are active. If this value is zero, then the database engine creates a default sort order where rgSortSpecs[0].propid = 0. This is only a placeholder and does not influence the insertion order of the records.
rgSortSpecs
[in] Pointer to an array of actual sort order descriptions. The size of the array is specified by wNumSortOrder. This parameter can be NULL if wNumSortOrder is zero.
Return Values
The object identifier of the newly created database, not a handle to an open database, indicates success. NULL indicates failure. To get extended error information within a Windows CE program, call GetLastError. The following table lists possible values for GetLastError.

Value Description
ERROR_DISK_FULL The destination source does not contain enough space to create the new database.
ERROR_INVALID_PARAMETER A parameter was invalid.
ERROR_DUP_NAME A database already exists with the specified name.

Remarks
Because sort orders increase the system resources needed to perform each insert and delete operation, keep the number of sort orders to a minimum. Use the CeSetDatabaseInfo function to change the sort order later.

Requirements
Runs on Versions Defined in Include Link to
Windows CE OS 1.01 and later Windbase.h Winbase.h Coredll.lib

See Also
CeCreateDatabaseEx, CeCreateDatabaseEx2, CeDeleteDatabaseEx, CeOidGetInfoEx, CeOpenDatabaseEx, CeSetDatabaseInfoEx, GetLastError, SORTORDERSPEC

COPYRIGHT NOTICE. Copyright 2002 Microsoft Corporation, One Microsoft Way, Redmond, Washington 98052-6399 U.S.A. All rights reserved.
 
END  ARTICLE




And notice here that it says that the CeOpenDatabase  function is obsolete

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceobjst/htm/cerefCeOpenDatabase.asp

BEGIN ARTICLE

Microsoft Windows CE .NET  

CeOpenDatabase
This function opens an existing database. This function is obsolete. Applications should call CeOpenDatabaseEx2 instead.

A RAPI version of this function exists, and it is also called CeOpenDatabaseEx (RAPI).

HANDLE CeOpenDatabase(
PCEOID poid,
LPWSTR lpszName,
CEPROPID propid,
DWORD dwFlags,
HWND hwndNotify
);
Parameters
poid
[in] Pointer to the object identifier of the database to be opened. To open a database by name, set the value pointed to by poid to zero to receive the object identifier of the newly opened database when a database name is specified for lpszName.
lpszName
[in] Pointer to the null-terminated string that contains the name of the database to be opened. This parameter is ignored if the value pointed to by poid is nonzero.
propid
[in] Property identifier of the key for the sort order in which the database is to be traversed. All subsequent calls to CeSeekDatabase assume this sort order. This parameter can be zero if the sort order is not important.
dwFlags
[in] Specifies a bitmask of action flags. It is one of the values listed in the following table.
Value Description
CEDB_AUTOINCREMENT Causes the current seek position to be automatically incremented with each call to the CeReadRecordProps function.
0 The current seek position is not incremented with each call to CeReadRecordProps.

hwndNotify
[in] Handle to the window to which notification messages (DB_CEOID_*) will be posted if another thread modifies the specified database while it is open. This parameter can be NULL if you do not need to receive notifications.
Return Values
The handle to the open database indicates success. INVALID_HANDLE_VALUE indicates failure. To get extended error information, call GetLastError. The following table lists possible values for GetLastError.

Value Description
ERROR_INVALID_PARAMETER A parameter was invalid.
ERROR_FILE_NOT_FOUND No database exists with the specified name. This value applies only if the value pointed to by poid was set to NULL when the function was called.
ERROR_NOT_ENOUGH_MEMORY No memory was available to allocate a database handle.

Remarks
Use the CloseHandle function to close the handle returned by the CeOpenDatabase function.

Unlike many other traditional databases, opening and closing a database does not imply any transactioning. In other words, the database is not committed at the closing  it is committed after each individual call.

An application that opens the same database more than once and requests to be notified about changes to the database will receive change notification for changes that its process has made on the database. The reason is that change notification process is not done on a process level, but on a per open database level.

Requirements
Runs on Versions Defined in Include Link to
Windows CE OS 1.01 and later Windbase.h Winbase.h Coredll.lib

See Also
CeCloseHandle, CeCreateDatabase, CeOpenDatabaseEx (RAPI), CeOpenDatabaseEx, CeSeekDatabase, CeOpenDatabaseEx2, GetLastError

COPYRIGHT NOTICE. Copyright 2002 Microsoft Corporation, One Microsoft Way, Redmond, Washington 98052-6399 U.S.A. All rights reserved.
 
END  ARTICLE
0
 
LVL 44

Expert Comment

by:CrazyOne
ID: 6904442
Oops never mind the CeCreateDatabase actually creates a new Database. I misread the information. Sorry. Also which version Of CE are you programming for?
0
 
LVL 10

Accepted Solution

by:
HDWILKINS earned 50 total points
ID: 6907388
I don't think you can open an mdb on a CE.

See: http://support.microsoft.com/default.aspx?scid=kb;EN-US;q254946

Which says in part:

On the Palm-size PCs that run Microsoft Windows CE 2.11, the database files are stored in .cdb file format, which is what Microsoft Pocket Access uses. When you move the Microsoft Access database file from the Desktop computer to the Palm-size PC, Microsoft ActiveSync converts the file from .mdb format to .cdb format.

Hope this helps

Harry
0
 
LVL 3

Expert Comment

by:ITsheresomewhere
ID: 7102803
  ***Request for Closing Action and Input *****  

Hi pratimag and participating Experts

The reason for contacting you is that your help is needed in closing this question
and bringing the queue up to date. pratimag, you will also be returning the courtesy
that Experts extended to you in responding to the original question.

Your choices are:

1. Select a comment which provided you with the solution or information needed to
 resolve the question.

2. Request a split of points among participating Experts by stating in a comment
which experts and in what amount each is to be awarded.   A Moderator will handle
the closing awards.   You may designate as many Experts as you wish.

Example 100 point question:

Please Split points to  (Expert1name) - 50 points, (Expert2name)- 50 points


3. Request the question be Closed and PAQ for 0 points if you resolved it yourself,
 or if no solution was found.

To do this go to http://www.experts-exchange.com/commspt/    
Post a 0 point question, requesting closing assistance.  Include your reasoning
and a reference to this question - copy and paste this question URL shown above.

Please also post your comment here as to why to inform the participating Experts.

I realize that two and three are a bit of a bother, but it is necessary and simplification
is in the works.

Experts-Exchange really does appreciate your cooperation.

Again thanks    - DO NOT ACCEPT THIS COMMENT AS THE ANSWER


ITsheresomewhere
EE Database Cleanup Volunteer


EXPERTS - Please monitor this question in the event that additional information or
clarification is needed by the Asker.  Your assistance in bringing this question to a
close is, as always, greatly appreciated.
          *****If you have closing suggestions please make them now. *****
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 3

Expert Comment

by:ITsheresomewhere
ID: 7130599
Hello pratimag,

It appears that you have abandoned this question as you have with more than 50% of all your questions.

I will ask Community Support to close it unless you finalize it within 7 days.  I will suggest to:

    DELETE this question - Abandoned No Refund No PAQ.

EXPERTS: Post a comment if you think somebody deserves credit here!

Please do not accept this comment as your answer!
==========
ITsheresomewhere
EE Database Cleanup Volunteer
0
 
LVL 10

Expert Comment

by:HDWILKINS
ID: 7130721
Honestly, I think my answer was the correct answer.  You can't open an MDB on a CE.  You must use a CDB.

Harry
0
 
LVL 44

Expert Comment

by:CrazyOne
ID: 7130789
Yeah I agree with Harry
0
 
LVL 3

Expert Comment

by:ITsheresomewhere
ID: 7130804
Thank you for both providing additional comments.

It would be extremely helpful if these comments could be placed at the time of the initial followup.  That is why the text specifically addressed to the Experts is included.  It may even assist the Asker in directly acting when the asker, even provided acurate information, is still incapable of making a fair decision.

The one significant element I missed was the askers inclusion of "cdb" in the question which would indicate at least some knowledge that further validates HDWilkins position.  

Since there is now concurrence I will modify the recommendation as follows:

            Award question to HDWILKINS and PAQ

Again, I thank you both for your input and ask your assistance in providing same at the initial followup.

ITsheresomewhere
EE DBCleanup Volunteer
0
 
LVL 10

Expert Comment

by:HDWILKINS
ID: 7131053
Thanks,

I'm not sure that I saw your first message (maybe I did and maybe I didn't) but I've made this suggestion before to other moderators and I'll replay it:  

If you could put your intentions in your first message, we'd be better able to respond to it.  i.e. Its an old question and if I don't hear from you, I'm going to give points to, or delete it or whatever.  That way, we know what your thinking.  Not only would we have something to look at, you'd have a record of your intentions in the posting when you go back to it the second time.  

Harry
0
 
LVL 5

Expert Comment

by:Netminder
ID: 7181346
Per recommendation, force-accepted.

Netminder
CS Moderator
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now