Link to home
Start Free TrialLog in
Avatar of dataxx
dataxx

asked on

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


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
 
ASKER CERTIFIED SOLUTION
Avatar of softev
softev

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial