In the following code, m_ListBox is a ListBox control.
MYSQL * myData; MYSQL_RES * myResult; CString str; MYSQL_ROW row; unsigned int num_fields; unsigned int I; unsigned long * lengths; m_ListBox.ResetContent (); ASSERT (m_ListBox.GetCount () = 0); if (myData = mysql_init (MYSQL *) 0) & mysql_real_connect (myData, NULL, "root", NULL, NULL, MYSQL_PORT, NULL, 0) // initialization, database connection, local connection, use root account, no password, default port {m_ListBox.AddString ("connection successful"); if (myResult = mysql_list_dbs (myData, "%") // enumeration database {m_ListBox.AddString ("enumeration database succeeded"); num_fields = mysql_num_fields (myResult ); // number of data structures for obtaining results while (row = mysql_fetch_row (myResult) // obtain data for the next row {lengths = mysql_fetch_lengths (myResult); for (I = 0; I
|