Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Unable to insert a record

Posted on 1998-09-25
6
Medium Priority
?
239 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
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!

 

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

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!

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
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…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

610 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