Unable to insert a record


I'm using MSSQL-Sererver 6.5 and MS Visual C++ 5.0 with the class CRecordset. I have no problems with reading the records. But when I try to add a record I get the error:

Recordset is read-only

The following lines are a part of my Program:

    Open();                     // -> returns 1
    m_pDatabase->BeginTrans();  // -> returns 0 ???
    AddNew();                   // -> DBException

Can anyone help me?
Who is Participating?
doubasConnect With a Mentor Commented:
as you said, the problem is your conversion of the string to the integer.  can you eliminate all conversion functions (convert() et al) from your select list and handle the conversions programmatically?

I'd probably check the permissions on the table in question in SQL Server.  You may have "select" granted, but not "update" or "insert".
the other I thing you missed is to set open options to read/write by default it may be readonly.
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

To Insert Records , CRecordset should be Dynaset type. This can be specified while creating the project using AppWizard , In Datasource option select dynaset  ,  by default it is snapshot (Read Only)

schmidAuthor Commented:
Thanks for your answer.
The option snapshot does not mean read-only,but the changes made by other users are not visible until the recordset is closed and then reopened.

Sorry, I didn't wrote that I use the recordset for two different tables. In the first table I convert a string into an integer. The second table is used to insert the record. One field of the record is the integer from the first table.

If I don't use the first table to convert the string I can insert the record (with option snapshot).
schmidAuthor Commented:
I need the conversion from the database, but I can use a second Recordset.

Thanks for the help.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.