Home > Database > Mysql Tutorial > 简单介绍MySQL API编程_MySQL

简单介绍MySQL API编程_MySQL

WBOY
Release: 2016-06-01 13:56:27
Original
822 people have browsed it

下文代码中的m_ListBox是一个ListBox控件。

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 ) )//初始化,连接数据库,本地连接,使用root账号,无密码,默认端口

 {

  m_ListBox.AddString("连接成功");

  if (myResult=mysql_list_dbs(myData, "%"))//枚举数据库

  {

   m_ListBox.AddString("枚举数据库成功");

   num_fields=mysql_num_fields(myResult);//获取结果的数据结构数目

   while ((row=mysql_fetch_row(myResult)))//获取下一行数据

   {

    lengths=mysql_fetch_lengths(myResult);

    for(i=0;i

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template