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!
greenbirdAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

inprasCommented:
Hi
Create UR project with databse support
UR recordsets will be created by wizard
If UR table name is like MYTAB then recordset will be CMytabSet

Open the recordset where ever U want to
CMytabSet rs;

rs.Open();

while(!rs.IsEOF())
{
  if(rs.m_Field1 == 'N' && rs.m_Field2 == 'N')
{
  rs.Edit();
  rs.Field3 = 'N';
 rs.Field1 = '';
 rs.Field2 = '';
 rs.Update()
}
else
{
  rs.Edit();
  rs.Field3 = 'Y';
 rs.Field1 = '';
 rs.Field2 = '';
 rs.Update()
}
Hope this helps
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
greenbirdAuthor Commented:
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!
0
greenbirdAuthor Commented:
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!
0
greenbirdAuthor Commented:
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!
0
greenbirdAuthor Commented:
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!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.