Solved

Unable to insert a record

Posted on 1998-09-25
6
235 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
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
Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

 

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 50 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

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

749 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