Hi all,
      I just want to get the values of a table.The result implemented is "Open 
OK!
  segmentation fault ". Why did I got this result ? The following is my code:
   
  #include <stdio.h>
#include <string.h>
#include "sqlite3.h"
main()
{
    char **errmsg;
    int ret;
    int rc;
      sqlite3 *db;
    char *sql = "SELECT * FROM light;";
    char ***resultp;
    int *nrow;
    int *ncolumn;
    ret = sqlite3_open("sensor.db",&db);
    if (ret)
    {
        fprintf(stderr, "Could not open database:%s\n", sqlite3_errmsg(db));
        exit (1);
    }
    else 
     {  printf("Open OK!\n");
        rc = sqlite3_get_table(db,sql,resultp,nrow,ncolumn,errmsg);
          printf("rc=%d\n",rc);
        if (rc)
         {
             fprintf(stderr,"can't open the table:%s\n",sqlite3_errmsg(db));
             exit(1);
         }
        else printf("open the table ok");
       }    
         
    sqlite3_close(db);
    printf("Close OK!");
}
   
  Thank you so much!

  zhangjie 
   

                
---------------------------------
 雅虎1G免费邮箱百分百防垃圾信
 雅虎助手-搜索、杀毒、防骚扰  

Reply via email to