Solved

Fields and Tables of the DataBase Created from VB5.0

Posted on 1998-09-09
3
190 Views
Last Modified: 2013-11-20
Hi,

I have created a database from VB5.0.
I want to ask whether I can open this database from
Visual C++ 5.0 wihtout knowing the name of the fields and table of the database.

Because I find if I use this function CDaoRecordSet::SetFieldValue() or CDaoRecordSet::GetFieldValue()

I need to know the field of the database
eg. CDaoRecordset *m_pRSDlg;
    m_pRSDlg->SetFieldValue(_T("Name of the field"),"the input data to the database");

Also, when I try to open the database, I also need to know
the name of the table:
eg. m_pRSDlg->Open(dbOpenDynaset,_T("Select * from [Users]");

Thus, if I have a database not created by me, how can I
open it and do some data modification on it?

Thanks
P.S. Can it be done on using the class CDaoRecordSet
0
Comment
Question by:ee_lcpaa
3 Comments
 
LVL 2

Expert Comment

by:rayb
ID: 1322001
You can find all sorts of things out about the database through code.  Look at some of the other methods of CDaoDatabase, specifically the GetTableDefInfo method.  You can also alter the database through the DAO C++ classes.  Good luck!
0
 

Accepted Solution

by:
bobbym earned 50 total points
ID: 1322002
Dear lc_paaa,
You can use CDaoRecordset::m_nFields to estimate the number of fields in a table and GetFieldValue(), SetFieldValue with index, not with a field name. But unfortunately you can not do that using the CDaoDatabase.
 So you have to touch here a little deeper I suggest :
1. Consider using the SDK C++ DAO classes that give you a full control over the hierachy and also are much, much like VB objects,

or

2. If you still want to use the CDaoXXXX classes of MFC you will have to manipulate the underlying Automation objects by yourself. You can read a Technical Note on this matter (I don't remember the number right now).

Hope this helped :)
0
 
LVL 4

Expert Comment

by:pagladasu
ID: 1322003
Using the CDaoTableDef, CDaoTableDefInfo classes with CDaoDatabase, you can obtain the table information.
For field information, use the CDaoFieldInfo class
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 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

22 Experts available now in Live!

Get 1:1 Help Now