Link to home
Start Free TrialLog in
Avatar of kean082198
kean082198

asked on

need help urgently

DearExperts,
My project is going to due soon....about a week or two from now..and this is what happened...after I got extension from the due date.
I have done my projects but unfortunately, I saved them in 2 files.
One is my project for image processing where I need to extract some
features out. And I have done that part. I am able to show the values out
in a messagebox.
Also, I did another project, for my database where I am suppose
to store those values I extracted out. Currently, in my database, I got
those values from access only.
How should I interact both of them together? Meaning I want to calculate the values
using the first file and store them automatically in the second file(database)
when I, let say click a menu item called STORE?
Avatar of duneram
duneram

Is this for a school assignment?   assuming it's not,
you
simply have to:

1) open your file,
2) extract the data
3) Open a connection to your db (perhaps odbc)
4) Open the table
5) Add a record
6) close the table
7) close the connection to the db

8) close your input data file
Avatar of kean082198

ASKER

Dear Duneram,
No it is not my assignment, it is my project. So basically these are the steps I need to do:
1. Open the file - the file where I calculate the 4 values, let say a, b, c, d. OK that is simple.
2. Extract the data - yup, the 4 values are extracted…got them as a, b, c, d and is able to display those values out when I click display on the menu bar.
3. Open a connection to the db - I don't know how to do this part. What commands should I write and where should I do it. Which part of the function
4. Open the table - I don't understand
5. Add a record - yup, I understand this, but how?
6. Close the table - what is the command
7. Close the connection to the db - no idea how?
8. Close your input data file - please help…

Please, sir I really need help here. Please show me the step by step source codes to achieve this thing. Desperately need help. Thank you.

Kean

Dear experts,
Please help...
Hi Kean,
You can derive a class from CRecordset, let's call it CMySet. While doing this, you can point (in the wizard) to a table or a sql-query and classmembers are automatically created for you (for example m_ID, m_Name, etc).
In your app, you create a database connection with CDatabase.

(
CDatabase mydb;
mydb.Open("ODBC-connectstring,...)

Then you can use CMySet.Open to open the table you need. After that you can say:
CMySet.AddNew();
  CMySet.m_ID=11;
  CMySet.m_Name="MelissaC"
CMySet.Update();

You can close the dataconnection and the recordset with their Close()-methods.
Succes!




Sounds like the answer to me...
ASKER CERTIFIED SOLUTION
Avatar of MelissaC
MelissaC

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Dear Melissa,
I still don't understand what you wrote there. I am a very weak Visual C++ programmer and I need your help to tell me the step by step to do the project. What you have written are still very vague to me.
Please help.
1. Deriving a class from CRecordset:
In Classwizard, click on "Add Class". You can choose between making a new class or creating a class that is a child of another (already existing) class (= a derivation class). Choose to make a class of an existing class, class CRecordset. Call it MyRecordset.
The classwizard lets you point to a table or a sql query in a database. In fact, it lets you point to a DSN (Data Source Name, you can make a DSN, which is in fact a pointer to a database, by clicking Start-Settings-Control Pannel-32bitODBC in windows).

The new class that you created with the classwizard will contain member variables, and the function DoFieldExchange. Whenever you open the recordset with the function MySet.Open(), the data from the table will be read into those member variables. You can scroll through the table by using functions like:
MySet.MoveFirst(), MySet.MoveLast(), MySet.MoveNext, etc.

2. Adding new records

CMySet.AddNew();        //create space to insert new record
     CMySet.m_ID=11;    //store value 11 in member variable m_ID of                         //MySet
     CMySet.m_Name="MelissaC"
                        //Store value "MelissaC" in member var.
                        //m_Name
CMySet.Update();        //Store the new values in the database
                //(in fact, the function DoFieldExchange is called)

You can close the dataconnection and the recordset with their Close()-methods.
Hope this explanation will get you on the right track!
Good Luck!