Solved

Beginners Question: File Dialog Box / Setting File Path

Posted on 2002-04-08
12
171 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
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
 

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 100 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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 be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

747 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

13 Experts available now in Live!

Get 1:1 Help Now