Home > Database > Mysql Tutorial > C语言调用MySQL函数

C语言调用MySQL函数

WBOY
Release: 2016-06-07 17:25:26
Original
1241 people have browsed it

MYSQL* m_pstConn;//为已建立的 MySQL数据库连接

MYSQL* m_pstConn;//为已建立的 MySQL数据库连接 

// 获取表名

 MYSQL_ROW tbl;   

MYSQL_RES * pResultSet = NULL;

pResultSet = mysql_list_tables(m_pstConn, NULL); 

while(tbl = mysql_fetch_row(pResultSet))

{
  printf("table:%s\n", tbl[0]);
 

}


//获取数据库名

MYSQL_ROW db; 

MYSQL_RES * pResultSet = NULL;

pResultSet = mysql_list_dbs(m_pstConn, NULL); 

while(db= mysql_fetch_row(pResultSet))
{
  printf("db:%s\n", db[0]);
 
 }

 

//获取字段名

MYSQL_FIELD *tbl;

MYSQL_RES * pResultSet = NULL;

pResultSet = mysql_list_fields(m_pstConn, "test_log", NULL);

while(tbl = mysql_fetch_field(pResultSet))
{
  printf("db:%s\n", tbl[0]);
 
}

 

//获取字段名

MYSQL_FIELD *tbl;

MYSQL_RES * pResultSet = NULL;

mysql_query(m_pstConn, "select * from test_log");

pResultSet = mysql_store_result(m_pstConn);

while(tbl = mysql_fetch_field(pResultSet))
{
  printf("db:%s\n", tbl[0]);
 }

 

//获取字段信息

MYSQL_FIELD *tbl;

MYSQL_RES * pResultSet = NULL;

mysql_query(m_pstConn, "select * from test_log");

pResultSet = mysql_store_result(m_pstConn);

while(tbl = mysql_fetch_field(pResultSet))
{
  printf("db:%s, %d, %d, %s\n", tbl[0], tbl->type, tbl->flags, tbl->name);
 
}

linux

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