1 message in com.mysql.lists.win32Problem compiling prog using C++ Api ...| From | Sent On | Attachments |
|---|---|---|
| Vinodkumar S | 22 Oct 2001 00:41 |
| Subject: | Problem compiling prog using C++ Api in VC++6![]() |
|---|---|
| From: | Vinodkumar S (S.Vi...@blr.spcnl.co.in) |
| Date: | 10/22/2001 12:41:19 AM |
| List: | com.mysql.lists.win32 |
Hello , i am newbie to Mysql, i want to use mysql along with mfc, but when i use SSQLS and vector my program does not compile , here is my sample code
can anyone help me out , its really frustrating
sql_create_3 (DUMMY, // struct name, 1, 3, // I'll explain these latter string, name, // type, id int, empno, string, dept)
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) { int nRetCode = 0;
// initialize MFC and print and error on failure if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) { // TODO: change error code to suit your needs cerr << _T("Fatal Error: MFC initialization failed") << endl; nRetCode = 1; } else { // TODO: code your application's behavior here.
try { Connection con (use_exceptions); con.connect("mysql_cpp_data"); Query query = con.query();
query << "select * from stock"; // You can write to the query object like you would any other ostrem
vector <DUMMY> res; query.storein (res);
vector <DUMMY>::iterator i; for (i = res.begin (); i != res.end (); i++) {}
} catch (BadQuery er) { // handle any connection // or query errors that may come up cerr << "Error: " << er.error << endl; nRetCode = -1;
} catch (BadConversion er) { // we still need to cache bad conversions incase something goes // wrong when the data is converted into stock cerr << "Error: Tried to convert \"" << er.data << "\" to a \"" << er.type_name << "\"." << endl; nRetCode = -1; }
}
return nRetCode; }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ VINODKUMAR S. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Success is not final, failure is not fatal: it is the courage to continue that counts" --- Winston Churchill SIEMENS COMMUNICATION SOFTWARE Phone Off : (+91)-80-559 4067-73 Extn. : 4513 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




