Link to home
Start Free TrialLog in
Avatar of greenbird
greenbird

asked on

combine certain fields in .mdb files

Hi,

i have a .mdb(Access) database file. i would like to combine certain fields into one field. say :

if A=='N' and B=='N' then
  delete A and B and insert C=='N'
else
  delete A and B and insert C=='Y'

i am very new to VC++ and know nothing abt it, and my project is goint to be due. so sad, struggle!  Pls help me!
source code are most welcomed!
thank u so much!
ASKER CERTIFIED SOLUTION
Avatar of inpras
inpras

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
Avatar of greenbird
greenbird

ASKER

Hi, inpras,

thanks a lot for ur valuable informaiton. however i am so new to VC++ that i even do not know how to create a project with database support. could u pls tell me ?

i am looking forward to ur reply eagerly.

thank u!
Hi, inpras,

well i managed to build a database project now.
i would like to update the databse when i click a button.

here are some codes:

(in CSectionForm.h)
      CSectionSet* m_pSet;

(in CSectionForm.cpp)

void CSectionForm::OnButton1()
{
// TODO: Add your control notification handler code here

// i copy the following code from online help, but not know
// whether it is related to my program

//      m_pSet = &GetDocument()->m_sectionSet;
 //    CRecordView::OnInitialUpdate();

CSectionSet rs;

                                    rs.Open();

                                    while(!rs.IsEOF())
                                    {
                                      if((strcmp(rs.m_HCATR,"N")==0)                                          &&(strcmp(rs.m_HCATL,"N")==0))
                                    {
                                      rs.Edit();
// here  always get an erro: Field3 is not a member
// but Field3 initially is not declared since i would like to add this //field , so how?
 rs.Field3 = strdup("N");
                                     rs.m_HCATR = strdup("");
                                     rs.m_HCATL = strdup("");
                                     rs.Update();
                                    }
                                    else
                                    {
                                      rs.Edit();
  rs.Field3 = strdup("Y");
                                                                                            rs.m_HCATR = strdup("");
                                     rs.m_HCATL =strdup("");
                                     rs.Update();
                                    }
}
}



this code seems not working, dunno why.
pls help asap!

thanks a lot!
Hi,

anothe problem is that i can not make the project as a single databse supported application. i mean i have a lot of formviews and dialogs, i only wnat to update the database when the user clicks a button in a dialog.  is it possible to achieve that without build a new project with database support?

thanks a lot!
Hi,Inpras

have u seen my email address? aibinbin@hotmail.com

well i wonder whether u have read my requirements for the program:

click a button on a FormView, then a dialog box is displayed.

in the dialog box, there is a clistbox and a button.
let user select which fields to combine in the clistbox.click the button on the dialog box, then update the database in the following way:

say the database have the following fields:

A1 A2 B1 B2 C1 C2

if (A1="Y" and A1 ="Y")
then delete A1 and A2
       and insert A3 = "Y"
else
    delete A1 and A2
    and insert A3="N"

lets say the user select "combine A1 and A2" in the clistbox, then the database fianlly will be like:

A3 B1 B2 C1 C2

thank u very much again and waiting for ur email!

thanks!