?
Solved

Beginners Question: File Dialog Box / Setting File Path

Posted on 2002-04-08
12
Medium Priority
?
176 Views
Last Modified: 2010-04-02
Hi:

This is related to the Visual C++ "Enroll" tutorial which can be found at MSDN online, and also in the Learner version of Visual C++.

I can get the app to run ok (it's basically just a form which connects to a database - in this case an Access database) and then displays the field contents in a few text boxes....all very straightforward stuff, which I've gotten to work ok.

However, when I run the program it always prompts the user (ie. "me") with a file dialog box to enter the path of the database (ie. select it from the file dialog), and so I'm trying to figure out two things:

a) where is the code that does the dialog box call - I've searched through and cant see it anywhere, notably searching for "FileDialog" amongst other things.

b) how would I go about hardcoding the pathname of the database that I want to use.

Thanks,
Davey
0
Comment
Question by:BigBuy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
12 Comments
 
LVL 12

Expert Comment

by:pjknibbs
ID: 6927507
a) If it's using a standard Windows open dialog you should be looking for GetOpenFileName(), which is the standard call for creating one of these. (I'm not sure what the MFC equivalent is, but it'd almost certainly be called CFileDialog()).

b) The easiest way (e.g. the one requiring least program modification) would be to copy the hardcoded path into the string used to open the database rather than passing it the return value from GetOpenFileName() (or whatever).
0
 

Author Comment

by:BigBuy
ID: 6927999
Ok, let me have a play around with that and get back to you - that certainly looks kinda useful though...thanks in advance.

Davey
0
 

Author Comment

by:BigBuy
ID: 6937185
Hmmm, don't see either GetOpenFileName() or CFileDialog() or similar...did a search but it came up with nothing that looked useful....

Any help appreciated
Davey
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:BigBuy
ID: 6937287
Hmmm, don't see either GetOpenFileName() or CFileDialog() or similar...did a search but it came up with nothing that looked useful....

Any help appreciated
Davey
0
 
LVL 12

Accepted Solution

by:
pjknibbs earned 400 total points
ID: 6938802
Right, I've had a look at the Enroll application, but the version I looked at used ODBC to access the appropriate database, so I'm not sure why you're getting a file dialog at all! Have you got a data source called "Student Registration" in your ODBC control panel?
0
 
LVL 12

Expert Comment

by:pjknibbs
ID: 6938803
Right, I've had a look at the Enroll application, but the version I looked at used ODBC to access the appropriate database, so I'm not sure why you're getting a file dialog at all! Have you got a data source called "Student Registration" in your ODBC control panel?
0
 

Author Comment

by:BigBuy
ID: 6939005
Hi again,

I'm actually using my own database, which works ok once I've selected it from the dialog. I did a little debugging and can see where it's going to as below:

<pre>
CString CSectionSet::GetDefaultConnect()
{
  return _T("ODBC;DSN=MS Access Database");
}
</pre>

...and then it goes off and does the dialog stuff. I went all the way to where the dialog gets displayed, and copied the string that gets returned, which is as follows:

"DSN=MS Access Database;DBQ=C:\MYDIR\Project\Enroll\db1.mdb;DefaultDir=C:\MYDIR\Project\Enroll;DriverId=281;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;"

and then remmed out the return _T code and tried just to return the string (which didn't work out too well)...I'm completely new to C++ so apologies for the dumb questions...:-)

Thanks for your time.
Davey
0
 

Author Comment

by:BigBuy
ID: 6939008
...forget the <pre> tags....I thought they might format the code a bit better...I guess HTML is turned off in here...

0
 

Author Comment

by:BigBuy
ID: 6939044
Where is the ODBC control panel located? I seem to have looked everywhere within the IDE for it but no luck. I have the Learning Edition of VC++ but I'm guessing it must be in there somewhere being as the said tutorial is for novices....
0
 
LVL 12

Expert Comment

by:pjknibbs
ID: 6941456
It's in Control Panel--you know, the one you use to modify normal system settings? However, looking at the connection string you have there, it looks like you're NOT using ODBC to connect to the database, in which case I'm not sure what's going on.

Incidentally, if you managed to debug through the code to the Open dialog, you must have been able to find it now?
0
 
LVL 11

Expert Comment

by:griessh
ID: 7009375
Dear BigBuy

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "pjknibbs"

comment(s) as an answer since you never gave more feedback.

If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points. The link to the Community Support area is: http://www.experts-exchange.com/commspt/

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 7024352
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

770 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