跳到內容
  • 版面
  • 最新
  • 標籤
  • 熱門
  • 使用者
  • 群組
  • 搜尋
  • Get Qt Extensions
  • Unsolved
Collapse
品牌標誌
  1. 首頁
  2. Qt Development
  3. General and Desktop
  4. [Solved]Program exited with code 0
Forum Updated to NodeBB v4.3 + New Features

[Solved]Program exited with code 0

已排程 已置頂 已鎖定 已移動 General and Desktop
49 貼文 3 Posters 31.2k 瀏覽 1 Watching
  • 從舊到新
  • 從新到舊
  • 最多點贊
回覆
  • 在新貼文中回覆
登入後回覆
此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
  • G 離線
    G 離線
    gayu
    寫於 最後由 編輯
    #29

    The '|' and '' should not seen in the database. Otherwise the output is correct.
    But, the thing is i need the stmt2 also enter to the database.
    for eg

    |Lotus\ is our national flower.

    In the above stmt, lotus is the phrase, and is our national flower is the stmt2.
    That stmt2 is not entering in database.

    And also tried with that code, also remain the same problem, the answers are not entering into the database.

    1 條回覆 最後回覆
    0
    • A 離線
      A 離線
      AlekseyOk
      寫於 最後由 編輯
      #30

      try to replace '' with '\'

      1 條回覆 最後回覆
      0
      • G 離線
        G 離線
        gayu
        寫於 最後由 編輯
        #31

        ya i tried by replacing '' with '\' Still it is not get inserting into the Answer table.

        1 條回覆 最後回覆
        0
        • G 離線
          G 離線
          gayu
          寫於 最後由 編輯
          #32

          So in my code instead of return -1, i replaced it by returning the index as return index.

          As in the switch case, in if condition i'm checking the condition as

          @
          if(option[index]=='\0')
          {
          cout<<"option[index]-----\n"<<option[index]<<endl;
          stmt1[j] = '\0';
          option[0] = '\0';
          //return -1; instead of this
          return (index); added this
          }
          @

          instead of this condition i replaced it as,

          @
          if(index!=-1) instead of this

          if((((Short *)object)->options[i])[index]!='\0') added this
          {
          query = new QSqlQuery("insert into ShAnsPts(Statement1,Statement2,Option1,QNo,PointNo,CorrectNo) values ("" + stmt1 + "", NULL,"" + phrase + ""," + temp2.setNum(qNo) + "," + temp2.setNum(((Short *)object)->ptno[i+1])+",1)");
          }
          @

          With the above condition what i've added it working fine.

          It is inserting into the Ques table and also in Ans table now. whether it is right or nt. Do you have any idea about this. Please tell me

          1 條回覆 最後回覆
          0
          • A 離線
            A 離線
            AlekseyOk
            寫於 最後由 編輯
            #33

            What is an "Answer table"?! We didn't speak about any insertion of data to Answer table. Check your SQL-queries for correctness.

            1 條回覆 最後回覆
            0
            • G 離線
              G 離線
              gayu
              寫於 最後由 編輯
              #34

              The answer table is where the options and stmt get parsed i.e Qt is a |Cross platform appln framework. is to be in the answer table.
              Surely i'll check the SQL-queries where i've to do the corrections.

              1 條回覆 最後回覆
              0
              • A 離線
                A 離線
                AlekseyOk
                寫於 最後由 編輯
                #35

                First of all - print all values on the screen
                Second - change SQL-query builder to the next:

                @
                query = new QSqlQuery("insert into ShAnsPts(Statement1,Statement2,Option1,QNo,PointNo,CorrectNo) values (?, ?, ?, ?, ?, ?)");
                query.addBindValue(stmt1);
                query.addBindValue(QVariant(QVariant::String)); // NULL string
                query.addBindValue(phrase);
                query.addBindValue(temp2.setNum(qNo));
                query.addBindValue(temp2.setNum(((Short *)object)->ptno[i+1]));
                query.addBindValue(1);
                @

                1 條回覆 最後回覆
                0
                • G 離線
                  G 離線
                  gayu
                  寫於 最後由 編輯
                  #36

                  Sorry for asking you again and again, please tell me
                  Instead of the following code
                  @
                  query = new QSqlQuery("insert into ShAnsPts(Statement1,Statement2,Option1,QNo,PointNo,CorrectNo) values ("" + stmt1 + "", NULL,"" + phrase + ""," + temp2.setNum(qNo) + "," + temp2.setNum(((Short *)object)->ptno[i+1])+",1)");
                  @

                  I've to add this code
                  @
                  query = new QSqlQuery("insert into ShAnsPts(Statement1,Statement2,Option1,QNo,PointNo,CorrectNo) values (?, ?, ?, ?, ?, ?)");
                  query.addBindValue(stmt1);
                  query.addBindValue(QVariant(QVariant::String)); // NULL string
                  query.addBindValue(phrase);
                  query.addBindValue(temp2.setNum(qNo));
                  query.addBindValue(temp2.setNum(((Short *)object)->ptno[i+1]));
                  query.addBindValue(1);
                  @

                  If means by adding this code it is showing the error as request for member ‘addBindValue’ in ‘query’, which is of non-class type ‘QSqlQuery

                  For printing the values on screen i already added the following code.

                  @index = parseOption(index,((Short *)object)->options[i],stmt1,phrase);
                  cout<<"index : "<<index<<"\n"<<stmt1<<"\n"<<phrase<<endl;
                  QString text11;
                  stmt1temp=stmt1;
                  cout<<"stmt1temp\n"<<stmt1<<endl;
                  stmt1=stmt1temp;
                  cout<<"stmt1\n"<<stmt1<<endl;
                  phrasetemp=phrase;
                  cout<<"phrasetemp\n"<<phrasetemp<<endl;
                  phrase=phrasetemp;
                  cout<<"phrase\n"<<phrase<<endl;@

                  1 條回覆 最後回覆
                  0
                  • A 離線
                    A 離線
                    AlekseyOk
                    寫於 最後由 編輯
                    #37
                    1. change '.' to '->'
                    2. What is an output of cout << *?
                    1 條回覆 最後回覆
                    0
                    • G 離線
                      G 離線
                      gayu
                      寫於 最後由 編輯
                      #38

                      index : 41
                      Qt is a
                      cross platform appln framework
                      stmt1temp
                      .
                      stmt1
                      .
                      phrasetemp
                      cross platform appln framework
                      phrase
                      cross platform appln framework

                      1 條回覆 最後回覆
                      0
                      • A 離線
                        A 離線
                        AlekseyOk
                        寫於 最後由 編輯
                        #39
                        1. As I can see your output doesn't contain any NULL-value. So, I think you have errors somewere else... Possibly, in SQL-table (e.g. wrong field type).
                        2. For what are you make such assignments:

                        @
                        ...
                        stmt1temp=stmt1;
                        cout<<"stmt1temp\n"<<stmt1<<endl;
                        stmt1=stmt1temp;
                        ...
                        @
                        ?

                        1 條回覆 最後回覆
                        0
                        • G 離線
                          G 離線
                          gayu
                          寫於 最後由 編輯
                          #40

                          For eg if i am entering the answer like this.
                          Android is a |Linux-based operating system\ designed primarily for touchscreen mobile devices.

                          In the following code,
                          @
                          index = parseOption(index,((Short *)object)->options[i],stmt1,phrase);
                          cout<<"index : "<<index<<"\n"<<stmt1<<"\n"<<phrase<<endl;
                          @
                          The stmt1temp,stmt1 is considered as Android is a
                          As you know, the phrasetemp,phrase is the same Linux-based operating system
                          By the following code,

                          @
                          stmt1=parseQuestion(stmt1); // function called for replacing tilde,cape symbol to angluar brackets
                          cout<<"stmt1--\n"<<stmt1<<endl;
                          stmt2temp=parseStepNo(stmt1,i,aPNo);
                          cout<<"stmt2temp\n"<<stmt2temp<<endl;
                          cout<<"\nThis is the apno value required"<<aPNo<<endl;
                          stmt2=stmt2temp;
                          cout<<"This is STatement2 value"<<stmt2<<endl;
                          @

                          The stmt1 is taken for stmt2 i.e designed primarily for touchscreen mobile devices.
                          The assignments are mainly made for parsing the options.

                          1 條回覆 最後回覆
                          0
                          • G 離線
                            G 離線
                            gayu
                            寫於 最後由 編輯
                            #41

                            Actually i missed some thing in the previous post

                            index : 40
                            Qt is a
                            cross platform appln framework

                            stmt1temp
                            Qt is a
                            stmt1
                            Qt is a
                            phrasetemp
                            cross platform appln framework
                            phrase
                            cross platform appln framework

                            After this
                            text11insert into ShAnsPts(Statement1,Statement2,Option1,QNo,PointNo,CorrectNo) values ("Qt is a ", NULL,"cross platform appln framework",4816,4816,1)

                            Then,

                            index : 41
                            Qt is a
                            cross platform appln framework
                            stmt1temp
                            .
                            stmt1
                            .
                            phrasetemp
                            cross platform appln framework
                            phrase
                            cross platform appln framework

                            1 條回覆 最後回覆
                            0
                            • G 離線
                              G 離線
                              gayu
                              寫於 最後由 編輯
                              #42

                              Also exactly not like that. As assigning the null values in the code for stmt1 and option it will take null values in the out put i.e when printing the output as Qt is a |cross platform appln framework.
                              In the above result
                              after printing the stmt1 Qt is a after this null value is seen.

                              1 條回覆 最後回覆
                              0
                              • G 離線
                                G 離線
                                gayu
                                寫於 最後由 編輯
                                #43

                                Instead of returning index value as -1

                                @
                                return -1;
                                @

                                I returned the index itself

                                @
                                return (index);
                                @
                                Also in the case SHORT:
                                Instead of checking the condition for executing query for inserting into answer table,

                                @
                                if(index=-1)
                                @

                                I checked the condition,
                                @
                                if((((Short *)object)->options[i])[index]!='\0')
                                @
                                Now it is working fine and all the questions and answers are entering to the main xml file also to the database in the appropriate table.

                                Thanks Lukas Geyer and thanks a lot Aleksey Okinchitc.

                                1 條回覆 最後回覆
                                0
                                • A 離線
                                  A 離線
                                  AlekseyOk
                                  寫於 最後由 編輯
                                  #44

                                  Nice))

                                  Add "[SOLVED]" to the topic's title

                                  1 條回覆 最後回覆
                                  0
                                  • G 離線
                                    G 離線
                                    gayu
                                    寫於 最後由 編輯
                                    #45

                                    Ok but how to add that please tell me :(

                                    1 條回覆 最後回覆
                                    0
                                    • A 離線
                                      A 離線
                                      AlekseyOk
                                      寫於 最後由 編輯
                                      #46

                                      Edit your first post

                                      1 條回覆 最後回覆
                                      0
                                      • G 離線
                                        G 離線
                                        gayu
                                        寫於 最後由 編輯
                                        #47

                                        In the title field i've to add [solved] am i right. :)

                                        1 條回覆 最後回覆
                                        0
                                        • A 離線
                                          A 離線
                                          AlekseyOk
                                          寫於 最後由 編輯
                                          #48

                                          Yes, you are right.

                                          1 條回覆 最後回覆
                                          0

                                          • 登入

                                          • Login or register to search.
                                          • 第一個貼文
                                            最後的貼文
                                          0
                                          • 版面
                                          • 最新
                                          • 標籤
                                          • 熱門
                                          • 使用者
                                          • 群組
                                          • 搜尋
                                          • Get Qt Extensions
                                          • Unsolved