int updateRow()
{
int rollno;
float gpa;
cout << " 輸入學號 :" ;
cin >> rollno ;
if(cin.fail( ))
{
cin.clear( );
cout<<"學號格式錯了";
return 0;
}
cout << " 輸入新的平均成績 : " ;
cin >> gpa;
if(cin.fail( ))
{
cin.clear( );
cout<<"成績格式錯了";
return 0;
}
std::stringstream strm;
strm << "update student set cgpa=" << gpa << " where roll=" << rollno ;
string s = strm.str();
char *str = &s[0];
//cout << str << endl;
sqlite3_stmt *statement;
int result;
//char *query="update student set cgpa=3.66 where roll=11";
char *query = str;
{
if(sqlite3_prepare(dbfile,query,-1,&statement,0)==SQLITE_OK)
{
int res=sqlite3_step(statement);
result=res;
sqlite3_finalize(statement);
}
return result;
}
return 0;
}
沒有留言:
張貼留言