c++获取mysql表的所有字段

c++获取mysql表的所有字段,第1张

c++获取mysql表的所有字段

mysql有一个指令是show full fields from 表名可以输出表的结构

#include

    MYSQL conn;    

    MYSQL_RES *result; 
    MYSQL_ROW row;

mysql_init(&conn);
    if (!mysql_real_connect(&conn, "服务器", "账号", "密码", "数据库名", 端口, NULL, 0)){
        MessageBox(NULL,L"连接失败!",NULL,NULL);
    string str = "show full fields from "+"表1";

    if (mysql_query(&conn,str.c_str()))   //若查询成功返回0,失败返回随机数
    {
        MessageBox(NULL,(CString)str.c_str()+L"执行失败!",NULL,NULL);
    }   

result = mysql_store_result(&conn);

while ((row = mysql_fetch_row(result))!=NULL)
    {
        MessageBox(NULL,(CString)row[0],NULL,NULL);
    }

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5155367.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-18
下一篇 2022-11-18

发表评论

登录后才能评论

评论列表(0条)

保存