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

Unable to insert a record

Hi!

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
    Update();
    Requery();
    m_pDatabase->CommitTrans();
    Close();


Can anyone help me?
0
schmid
Asked:
schmid
1 Solution
 
formulaCommented:
I'd probably check the permissions on the table in question in SQL Server.  You may have "select" granted, but not "update" or "insert".
0
 
odessaCommented:
the other I thing you missed is to set open options to read/write by default it may be readonly.
0
 
EzhilCommented:
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)



0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
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).
0
 
doubasCommented:
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?

doug
0
 
schmidAuthor Commented:
I need the conversion from the database, but I can use a second Recordset.

Thanks for the help.
0

Featured Post

Independent Software Vendors: 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!

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