I'm writing a Win32 application that uses MySQL C API...(package MySQL for DevC++)...
I got the connection, I can execute queries, but I don't know how to display results from a query(in main window)...?
thanks for help!
I'm writing a Win32 application that uses MySQL C API...(package MySQL for DevC++)...
I got the connection, I can execute queries, but I don't know how to display results from a query(in main window)...?
thanks for help!
Either make your application a console window and use std::cout,
or
http://www.winprog.org/tutorial/
gg
I managed to print the results into Listbox in a Dialog, but I've got few problems:
1. If I only select ID from query, I've got about 7 lines for each row (some weird characters) and only one is ID.
2. I can't use characters, used in windows-1250 encoding (characters are replaced by sings like ® © and so on....).
Thanks for help in advance...
Part of code:
Code:char *query; query = "SELECT id FROM table"; mysql_query(&mysql, query); result = mysql_store_result(&mysql); num = mysql_num_rows(result); while((row = mysql_fetch_row(result))) { UINT length; length = (UINT)mysql_fetch_lengths(result); for(UINT i = 0; i < num; i++) { SendDlgItemMessage(hwnd, IDC_LST1, LB_ADDSTRING, 0, (LPARAM)row[i]); }
Last edited by publikum; 01-27-2005 at 10:57 AM.
[C++]
IDE: DevC++ 4.9.9.2 (GCC 3.4.2)
2nd compiler: g++ (GCC 3.4.3/4.0.0)
3rd compiler: Borland 5.5
[C#]
IDE: Microsoft Visual C# Express 2005
2nd IDE: SharpDevelop
2nd compiler: csc in Command Prompt
.NET Framework: 2.0
[PHP]
Core: 5.1.0 beta 3
IDE: PHPEdit
2nd IDE: Notepad
Favourite extensions: exif,gd2,mysql
Favourite PEAR packages: DB, XML_RSS, ID3
Favourite databases: SQLite, MySQL
Code:char *query; query = "SELECT id FROM table"; mysql_query(&mysql, query); result = mysql_store_result(&mysql); num = mysql_num_rows(result); while((row = mysql_fetch_row(result))) // What's the datatype for the variable "row"? { UINT length; length = (UINT)mysql_fetch_lengths(result); for(UINT i = 0; i < num; i++) { SendDlgItemMessage(hwnd, IDC_LST1, LB_ADDSTRING, 0, (LPARAM)row[i]); }
It's MYSQL_ROW...
But never mind...I figured out
[C++]
IDE: DevC++ 4.9.9.2 (GCC 3.4.2)
2nd compiler: g++ (GCC 3.4.3/4.0.0)
3rd compiler: Borland 5.5
[C#]
IDE: Microsoft Visual C# Express 2005
2nd IDE: SharpDevelop
2nd compiler: csc in Command Prompt
.NET Framework: 2.0
[PHP]
Core: 5.1.0 beta 3
IDE: PHPEdit
2nd IDE: Notepad
Favourite extensions: exif,gd2,mysql
Favourite PEAR packages: DB, XML_RSS, ID3
Favourite databases: SQLite, MySQL
Code:mysql_real_query(&mysql, query, strlen(query)); result = mysql_store_result(&mysql); num = (UINT)mysql_num_fields(result); while(row = mysql_fetch_row(result)) { UINT *length; length = (UINT *)mysql_fetch_lengths(result); for(UINT i = 0; i < (UINT)num; i++) { strncpy(data, row[i], (int)length[i]); SendDlgItemMessage(hwnd, IDC_LST1, LB_ADDSTRING, 0, (LPARAM)row[i]); } }
[C++]
IDE: DevC++ 4.9.9.2 (GCC 3.4.2)
2nd compiler: g++ (GCC 3.4.3/4.0.0)
3rd compiler: Borland 5.5
[C#]
IDE: Microsoft Visual C# Express 2005
2nd IDE: SharpDevelop
2nd compiler: csc in Command Prompt
.NET Framework: 2.0
[PHP]
Core: 5.1.0 beta 3
IDE: PHPEdit
2nd IDE: Notepad
Favourite extensions: exif,gd2,mysql
Favourite PEAR packages: DB, XML_RSS, ID3
Favourite databases: SQLite, MySQL