Solved

Unable to insert a record

Posted on 1998-09-25
6
233 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS SQL with ODBC 5 36
SQL Replication question 9 43
Need a SQL query that creates a header row and one or more detail rows. 7 34
SQL server vNext 18 29
When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

777 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