Improve company productivity with a Business Account.Sign Up

x
?
Solved

Beginners Question: File Dialog Box / Setting File Path

Posted on 2002-04-08
12
Medium Priority
?
181 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
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 

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

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

606 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