sprintf(SqlStr, "select hwyf,hwrq,hwbc,hwcd,hwgh,hwxm,hwje,hwbz,hwzj,hwsj from %s ",TabName); printf("[%s]\n",SqlStr);
if(mysql_query (&mysql, SqlStr) != 0)
   {
     g_print ("数据库查询失败!");
     return ;
   }
    g_print ("数据库查询成功!");
 result = mysql_store_result (&mysql); while((row = mysql_fetch_row(result)) != 0)
        gtk_clist_appen (GTK_CLIST(m_list), row);//数据插入LIST 控件,文本显示的全是?号


解决方案 »

  1.   

    有问题吧,你现在是:select 字符 from table;
             你可以: select 字符/* from table where fieldname=字符;
      

  2.   

      g_print("进入查询");
      gtk_clist_clear(GTK_CLIST(m_list));  
        MYSQL mysql;
         MYSQL_RES *result;
         MYSQL_ROW row;
    time_t timep;
    struct tm *ptm;
    time(&timep);
    ptm = localtime(&timep);

    mysql_init(&mysql);
    if (!mysql_real_connect(&mysql,DBhost,DBuser,DBpasswd,SDBname,0,NULL,0))  
    {
    g_print("数据库连接失败!\n");
    return ;
    }       g_print("连接数据库成功\n");

    char SqlStr[2000];
    char TabName[50];
    char tmp_sql[500];

    memset(SqlStr,0,sizeof(SqlStr));
    memset(TabName,0,sizeof(TabName));
    memset(tmp_sql,0,sizeof(tmp_sql));
    sprintf(TabName,"hwl%d%s",(1900+ptm->tm_year),StationNO);
    sprintf(SqlStr, "select hwyf,hwrq,hwbc,hwcd,hwgh,hwxm,hwje,hwbz,hwzj,hwsj from %s ",TabName); printf("[%s]\n",SqlStr);
    if(mysql_query (&mysql, SqlStr) != 0)
       {
         g_print ("数据库查询失败!");
         return ;
       }
        g_print ("数据库查询成功!");
       result = mysql_store_result (&mysql);
        while((row = mysql_fetch_row(result)) != 0)
            gtk_clist_append (GTK_CLIST(m_list), my_row
      

  3.   

    首先你要保证你数据库的编码格式正确;然后在你的程序中 if(mysql_query (&mysql, SqlStr) != 0) 语句之前加上下面这条语句:
    mysql_real_query(&mysql,"set names  gbk",(unsigned int) strlen("set names  gbk"))
    这样在你的编辑器中显示出来的就是中文了