Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Opening ODBC connection

Posted on 2000-03-22
3
Medium Priority
?
238 Views
Last Modified: 2013-11-20
Hi... i am trying to create a connection to my odbc database object (access
97 object) and even though i specify a .mdb and table name in the wizard i
still get a prompt for an mdb file on initialization.

how do i stop this?

also, can anybody point me towards a basic framework example of this being implemented? all the examples i see are of specific problems being solved, and dont show the basic connection stuff.

finally, is a nice FAQ for beginners in vc++ database programming ?

thanx in advance
-Paul




0
Comment
Question by:Sesh
[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
3 Comments
 

Expert Comment

by:wardkd
ID: 2648572
Have you set up the ODBC driver to look at your database file???
0
 
LVL 1

Accepted Solution

by:
carldean earned 600 total points
ID: 2649186
If you've done everything by the wizard approach then you've probably got...

1. An ODBC datasource pointed at your .MDB file.
2. A class-wizard generated CRecordset class that maps on to a table or query in your .MDB file.
3. A problem that when you run it it autmatically asks you what datasource to connect to.

If this is the case and you don't want this to happen then ...

A. The reason this happens is because the CDatabase* parameter on the CRecordset constructor is defaulted to NULL.  In such cases when you call CRecordset::Open it creates a temporary CDatabase object and pops up the ODBC DSN Select dialog so that you may choose a datasource.
B. To avoid this, create, programattically, your own CDatabase object and pass a pointer to it in your CRecordset constructor.

i.e. ...

CDatabase myDb();
myDb.open("MyDataSource", FALSE, FALSE, "ODBC;UID=FRED;PWD=DOG");

CMyRecordset myRecs(&myDb);
myRecs.Open();

0
 
LVL 3

Expert Comment

by:V_Bapat
ID: 2660046
Since you have access database, I would suggest you use DAO classes provided by MFC.
Take a look at DaoTable and DaoView samples from MSDN.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

705 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