Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1094
  • Last Modified:



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);

      RecDonnees.Open(CRecordset::dynaset,                  "SELECT * FROM MERSENNE");


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"?
3 Solutions
RecDonnees(Champ)=Test; <== this is wrong RecDonnees is not function.....

you can do like :


thebestdave76Author Commented:
I tried RecDonnees.Champ=Test;
I had this message :
error C2039: 'Champ' : is not a member of 'CRecordset'
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

thebestdave76Author Commented:
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?
The problem (as you may have discovered) is that the CRecordset class itself isn't designed for writing values into the recordset simply.

The simple solution is to use the class wizard to create a new class, based on CRecordset and select the table you want as part of the wizard process.  Then you can use code like
rs.m_sChamp = "Test";

A more complex way is to write your own (generic) CRecordset based class which you code the data transfer functions yourself.

A complete alternative is to forget about ODBC and use an alternative such as ADO.  That will allow you to write simple code like you tried to do.
thebestdave76Author Commented:
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?
>>I tried the alternative ADO but there is a lot of errors on msjro.tlh during the compilation.

There is solution given for errors here == > http://www.codeproject.com/database/caaadoclass1.asp?select=800391&df=100&forumid=2115&fr=356.5#xx800391xx

Look at comments at the end of the article.

#pragma warning (disable: 4146)
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" \
rename("EOF", "EndOfFile") \
rename("ParameterDirectionEnum", "_ParameterDirectionEnum") \
rename("DataTypeEnum", "_DataTypeEnum")
#import "C:\Program Files\Common Files\System\ado\msjro.dll" \
no_namespace \
rename("ReplicaTypeEnum", "_ReplicaTypeEnum")
using namespace ADODB;
#pragma warning (default: 4146)


Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now