c++
  • mysql
  • 2014-02-19 65 views 0 likes 
    0

    代碼:的Mysql查詢錯誤

    MYSQL *con = mysql_init(NULL); 
    MYSQL_RES* result; 
    MYSQL_ROW row; 
    
    void student_login(string enrollno,string passwd) 
    { 
    
        if(mysql_query(con,"SELECT * FROM user_student WHERE ENROLLMENTNO='enrollno' ")) 
        { 
         finish_with_error(con); 
        } 
    
        result=mysql_store_result(con); 
        if(result==NULL) 
         finish_with_error(con); 
    
        int num_fields=mysql_num_fields(result); 
    
        while ((row = mysql_fetch_row(result))) 
        { 
         for(int i = 0; i < num_fields; i++) 
         { 
          printf("%s ", row[i] ? row[i] : "NULL"); 
         } 
    
         printf("\n"); 
        } 
    
        cout<<" i m done"; 
    } 
    

    數據庫:

    `enrollmentno  password` 
    

    我收到訪問衝突的錯誤。當我使用斷點進行調試時,問題似乎在mysql_fetch_row函數中。

    +0

    這不能完成;結果在哪裏申報? –

    +0

    我已經編輯了post.plz檢查... – user3311810

    回答

    0

    您已使用row=mysql_fetch_row(result);兩次。

    刪除此行row=mysql_fetch_row(result);

    +0

    thanx ...但是沒有幫助...我的while循環沒有被執行。 – user3311810

    相關問題