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);
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)