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!
Printable View
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]);
}
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 ;)
Wait! No! What was the answer? :)
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]);
}
}