In MySQLAPI programming, m_ListBox is a ListBox control in the following code.
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, "%") // enumerate databases
{
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 the data of the next row
{
Lengths = mysql_fetch_lengths (myResult );
For (I = 0; I