Link to home
Create AccountLog in
Avatar of thebestdave76
thebestdave76

asked on

CRecordset::Addnew

Hi,

I've got a database named "baseref". In this DB there is a table Named "MERSENNE". In this Table there is a column named "Simu1". I'd like to add a record in the table "MERSENNE" so I wrote this program :

CAleatoire::CAleatoire(CDatabase *baseRef)
{
      CString Test;
      CString Champ;
      
      CRecordset RecDonnees(baseRef);

      Champ="Simu1";
               Test="ee";
      RecDonnees.Open(CRecordset::dynaset,                  "SELECT * FROM MERSENNE");

      RecDonnees.AddNew();
      RecDonnees(Champ)=Test;
      RecDonnees.Update();
}

When I compile this program, the line "RecDonnees(Champ)=Test" is on error :

error C2064: term does not evaluate to a function

What have I have to do to add a record to my table "MERSENNE"?
Avatar of mahesh1402
mahesh1402
Flag of India image

RecDonnees(Champ)=Test; <== this is wrong RecDonnees is not function.....

you can do like :

     RecDonnees.AddNew();
     RecDonnees.Champ=Test;
     RecDonnees.Update();

MAHESH
SOLUTION
Avatar of rajeev_devin
rajeev_devin

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of thebestdave76
thebestdave76

ASKER

I tried RecDonnees.Champ=Test;
I had this message :
error C2039: 'Champ' : is not a member of 'CRecordset'
To rajeev_devin :

I checked your link but I have had the same error when I wrote "StrCopy(RecDonnees("Simu1"), "ee");"

What can I do to insert a new record?
SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
I tried the alternative ADO but there is a lot of errors on msjro.tlh during the compilation.

I don't have the class Wizard on my Visual C++, it is disabled.
How can I do to select the table I want as part of my new class?
ASKER CERTIFIED SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.