|
/********************************************************************
created: 2/8/2007
filename: mytest.C
contact: hongpinglin@hotmail.com
purpose:
*********************************************************************/
//
// SYSTEM INCLUDE
//
//
// PROJECT INCLUDE
//
//
// LOCAL INCLUDE
//
#include "mysql_client_simple_conn.h"
using namespace sbs_mysql_simple;
int Test1()
{
string query="select * from ordering_error_code";
CMysqlConn conn("sdb1.alpha.sbs.corp.yahoo.com",
"monitoring",
"richlin",
"richlinpw"
);
if (conn)
{
CMysqlSet rset=conn.Query<WithData>(query);
if (rset)
{
cout<<"I got a result"<<endl;
unsigned size=rset.NumberOfRecords();
cout<<size<<" response with "<<rset.NumberOfFields()<<" columns from the query '"<<query<<"'"<<endl;
for (unsigned int i=0;i<size; i++)
{
CMysqlRow row=rset.GetNextRow();
if (row)
{
for (unsigned int j=0; j<row.NumberOfFields();j++)
{
cout<<"\t"<<row[j];
}
cout<<endl;
}
}
}
cout<<"Last error is "<<conn.GetLastErrorCode()<<":"<<conn.GetLastErrorString()<<endl;
string updateQuery="insert into ordering_error_code values (5000, 'testing message')";
conn.Query<NoData>(updateQuery);
//
// Query single data test
//
cout<<"query single data..."<<endl;
pair<bool, string> value=conn.Query<CheckOneRecord>("select errorcodes from ordering_error_code where errorcode='2005'");
if (value.first)
{
cout<<"get value of "<<value.second<<endl;
}
}
return 0;
}
int main(int argc, char** argv)
{
Test1();
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Richard Lin is senior software engineer of in Silicon Valley.
Richard Lin was born in Beijing and came to US in the fall of 1995. He began his first software career in bay area of California in 1997. He has worked for many interesting projects including manufacturing testing systems, wireless AP firmware and applications, email anti-virus system and personal firewalls. He loves playing go (WeiQi in Chinese) and soccer in his spare time. He has a beautiful wife and a cute daughter and enjoys his life in San Jose of California.