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
Solved

How to fully access SQL server database with VC++5.0?

Posted on 1998-08-20
1
345 Views
Last Modified: 2010-04-01

I built a SQL server database with MS-SQL 6.5. I want to use MS VC++ 5.0 to access the database, such as, add, retrieve, delete records and etc.

So, after I built the database within MS SQL server "Enterprise Manager", I setup "ODBC database source" within "ODBC(32bit)" in Control Panel. Then, I add a MFC class "Myrecord" based on "CRecordSet".

At first, in my VC++5.0 source code, I use "CRecordSet::Open()" to open the database (No any parameters in "Open()", as the MS example shows). Then, I use "CRecordSet::AddNew()" or "CRecordSet::Edit()"  and "CRecordSet::Update()" to add or modify records in the database. However, right after the program executes "AddNew()" or "Edit()", there is a dialog box poped up: "Recordset is read-only".

So, I can't add or modify records in the database that I built and setup. Is the problem within SQL server database, or within the VC++ problem? From the VC++ help, I know that using "CRecordSet:Open()" (without any parameters) mean that the opened database can be fully accessed. However, why did it show "RecordSet is read-only"?

BTW, when I built my VC++ project with the "File->New" MFC AppWizard (multiple Document), in the step 2 of 6, I choosed "Header files only".

Now, I can only retrieve the records in the database but not add or delete. However, I am eager to fully access the database. Could you please help me figure out the problem?

Thank you very much!

--
Dataxx
 
0
Comment
Question by:dataxx
1 Comment
 
LVL 1

Accepted Solution

by:
softev earned 200 total points
ID: 1170785
Dataxx,

Look into creating a CDatabase object and passing into the
constructor of your CRecordSet object during construction time.
You'll be able to set properties on the CDatabase object that
allow for read/write...

Softev

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

860 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