帮助!我将使用select语句从oracle数据库中检索数据并加载到向量。
SELECT *From table
其中table包含超过100个元素的ID,NAME和Age
....所以我可以使用resultset.
使用c ++(控制台)检索值的简单技术
.........
//here my struct first.
struct adopp
{
int age,
string name;
string id;
};
//the vector to load
vector<string> load()
{
oc::Environment* evt = oc::Environment::createEnvironment(oc::Environment::DEFAULT);//oracle::occi::
oc::Connection* con=evt->createConnection("usr","psw", "db");
string sqlQuery = "SELECT * FROM table";
oc::Statement *sttmnt = con->createStatement(sqlQuery);
oc::ResultSet* rset = sttmnt->executeQuery();
vector<string>vet;
adopp adp;
while(rset->next())
{
string iddd= rset->getString(1);
adp.id=iddd;
vet.push_back(iddd);
string nameee= rset->getString(2);
adp.name=nameee;
vet.push_back(nameee);
int age=rset->getint(3);
adp.age=ageee;
vet.push_back(ageee);
}
con->terminateStatement(sttmnt);
evt->terminateConnection(con);
oc::Environment::terminateEnvironment(evt);
return vet;
}
错误/异常弹出消息显示:
Unhandled exception at 0x53cbad4a (msvcp100d.dll) in Test_project_L.exe: 0xC0000005: Access violation reading location 0xccccccd0.
感谢您的帮助。
答案 0 :(得分:0)