• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 179
  • Last Modified:

Beginners Question: File Dialog Box / Setting File Path

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
BigBuy
Asked:
BigBuy
1 Solution
 
pjknibbsCommented:
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
 
BigBuyAuthor Commented:
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
 
BigBuyAuthor Commented:
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 new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
BigBuyAuthor Commented:
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
 
pjknibbsCommented:
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
 
pjknibbsCommented:
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
 
BigBuyAuthor Commented:
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
 
BigBuyAuthor Commented:
...forget the <pre> tags....I thought they might format the code a bit better...I guess HTML is turned off in here...

0
 
BigBuyAuthor Commented:
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
 
pjknibbsCommented:
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
 
griesshCommented:
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
 
MindphaserCommented:
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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now