?
Solved

Unable to insert a record

Posted on 1998-09-25
6
Medium Priority
?
238 Views
Last Modified: 2010-03-19
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
Comment
Question by:schmid
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 2

Expert Comment

by:formula
ID: 1090263
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
 
LVL 2

Expert Comment

by:odessa
ID: 1090264
the other I thing you missed is to set open options to read/write by default it may be readonly.
0
 
LVL 2

Expert Comment

by:Ezhil
ID: 1090265
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
Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

 

Author Comment

by:schmid
ID: 1090266
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
 

Accepted Solution

by:
doubas earned 100 total points
ID: 1090267
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
 

Author Comment

by:schmid
ID: 1090268
I need the conversion from the database, but I can use a second Recordset.

Thanks for the help.
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question