Home > Software engineering >  MFC connection "record set read-only" problem when the ODBC data source, and the prompt ef
MFC connection "record set read-only" problem when the ODBC data source, and the prompt ef

Time:09-22

CodePudding user response:

Code on the Open is how call?

CodePudding user response:

CSubjectinfo * mysubjectset; (CSubjectinfo is a CRecordset class derived classes, and a data table together.)
//set the SQL statement
Cstrings SQL;
SQL="SELECT * FROM tb_subject";
Mysubjectset=new CSubjectinfo (& amp; (((CSubjectManageApp *) AfxGetApp ()) - & gt; M_DB));

if(! Mysubjectset - & gt; Open (AFX_DB_USE_DEFAULT_TYPE, SQL))
{
AfxMessageBox (" tb_subject table open failure!" );
}

CodePudding user response:

Below is the code, bosses and see where the trouble caused the "record set read-only" this problem, need to solve, thank you bosses,
I use the compiler is vc + + 6.0, the database is SQL Server 2014 Express, the connection of the data source is a 32-bit ODBC data source
(this is the data in the database table picture)
https://pan.baidu.com/s/16wxIfm8QBWpnSrKfAjPOpw (this is a code file, just only one class, trouble bosses run and see where there is a problem, thank you very much)

CodePudding user response:

Couldn't the program compiled by

CSubjectManageApp: : InitInstance of data source initialization should be given before DoModal

CodePudding user response:

Sorry, a semicolon into Chinese version, correct, also the CSubjectManageApp: : InitInstance of data source initialization should be placed before DoModal, but still hint "recordset is read-only"

CodePudding user response:

For bosses to help take a look at where there are problems, help change, I need to correct it to run, if you can send me see change good code, by the way, could you show me your Settings is how to set up the ODBC data source,

CodePudding user response:


Is from mysubjectset - & gt; AddNew (); Then I make a mistake, prompt "recordset is a read-only"
  • Related