How to fully access SQL server database?
Posted on 1998-08-20
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!