Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Creation SQLITE database
Forum Updated to NodeBB v4.3 + New Features

Creation SQLITE database

Scheduled Pinned Locked Moved Unsolved General and Desktop
20 Posts 4 Posters 3.2k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Nafab213N Nafab213

    Hi
    I want each user to give the name of their choice .. how do I do that for that?

    So I put the bttncreate as an example.
    My real problem is the database and the table.
    If you have read the code .. You will see that everything is not correct.
    Thnks...

    JonBJ Online
    JonBJ Online
    JonB
    wrote on last edited by JonB
    #4

    @Nafab213
    I'm not going to write the code for you (perhaps someone else will), but prompt the user for the desired filename in newfiledb(), or something similar.

    If you have read the code .. You will see that everything is not correct.

    Since you seem to know this, would you like to provide a hint as to what is wrong or an error message or something, or would you like us to figure it out ourselves as an exercise? https://stackoverflow.com/questions/27844759/how-to-create-a-sqlite-database-in-qt gives sample code, yours looked vaguely along the same lines to me....

    1 Reply Last reply
    2
    • Nafab213N Offline
      Nafab213N Offline
      Nafab213
      wrote on last edited by
      #5

      Thanks....
      I do not ask you to write me the code but I want to know how to proceed.
      Qaund I'm talking about problem, I think first on the board.
      I know it's encouraging laziness if you write it to me but I've already read dozens of courses and tried to write the beginning of the code. When I read them, I do not really understand the courses when I see practical examples on projects and that's how I wrote the first part of my code.
      If you've got me an identical project you've worked on or something else, I'll take some examples.
      There are cells that are merging or split but I do not know how to put it in the code. Also the five empty lines of the table will be shown in the table but I do not know how to do it.
      It's just an intuition of realism. If I do not decipher it, it will not appear but I want to know how to do it.

      JonBJ 1 Reply Last reply
      0
      • Nafab213N Nafab213

        Thanks....
        I do not ask you to write me the code but I want to know how to proceed.
        Qaund I'm talking about problem, I think first on the board.
        I know it's encouraging laziness if you write it to me but I've already read dozens of courses and tried to write the beginning of the code. When I read them, I do not really understand the courses when I see practical examples on projects and that's how I wrote the first part of my code.
        If you've got me an identical project you've worked on or something else, I'll take some examples.
        There are cells that are merging or split but I do not know how to put it in the code. Also the five empty lines of the table will be shown in the table but I do not know how to do it.
        It's just an intuition of realism. If I do not decipher it, it will not appear but I want to know how to do it.

        JonBJ Online
        JonBJ Online
        JonB
        wrote on last edited by JonB
        #6

        @Nafab213
        I'm sorry but I simply don't happen to have code written which will do what you want. Perhaps someone else will, so I will not comment after this.

        But I will say that others will find it difficult when your questions keep changing completely. First off I believe your push button was simply not being displayed, so I don't know what you were doing. Then you said you wanted to know how to create a database in SQLite. But now you are saying what you want to know are questions about cells merging, empty lines etc., which is simply in complete contradiction to not being able to connect to a database.

        So I don't intend to be rude, but I think you should consider what your actual question is, for others to answer.

        1 Reply Last reply
        0
        • Nafab213N Offline
          Nafab213N Offline
          Nafab213
          wrote on last edited by
          #7

          @JonB said in Creation SQLITE database:

          I'm sorry but I simply don't happen to have code written which will do what you want. Perhaps someone else will, so I will not comment after this.
          But I will say that others will find it difficult when your questions keep changing completely. First off I believe your push button was simply not being displayed, so I don't know what you were doing. Then you said you wanted to know how to create a database in SQLite. But now you are saying what you want to know are questions about cells merging, empty lines etc., which is simply in complete contradiction to not being able to connect to a database.
          So I don't intend to be rude, but I think you should consider what your actual question is, for others to answer.

          Excuse me then ..
          Let's focus on the SQLITE database.
          Look at the code of the database.
          Is this correct?

          1 Reply Last reply
          0
          • Nafab213N Offline
            Nafab213N Offline
            Nafab213
            wrote on last edited by
            #8

            Excuse me then ..
            Let's focus on the SQLITE database.
            Look at the code of the database.
            Is this correct?

            Thanks

            JonBJ 1 Reply Last reply
            0
            • Nafab213N Nafab213

              Excuse me then ..
              Let's focus on the SQLITE database.
              Look at the code of the database.
              Is this correct?

              Thanks

              JonBJ Online
              JonBJ Online
              JonB
              wrote on last edited by
              #9

              @Nafab213
              No, because I spot

              "Sexe varcher (1)"
              

              But then, politely, I didn't realise I was responsible for spotting spelling mistakes, having to look at every single character in what you have typed.

              And then you also have:

                                  "Varchar(20), "
                                  "matiere(20),"
              

              which are both obviously wrong. And nobody could possibly write this correctly for you, because they won't know what you actually want.

              If you are going to have this level of problem, I would suggest you get hold of whatever equivalent of MySQL Workbench that SQLite provides (I know it provides something similar) and get the SQL code working there each time, before you copy it into your Qt code. You will get much better help on mistakes etc. interactively in a tool like that than direct from Qt code. This is not an "annoyance" for you, it looks like you really do need to do that in order to get anywhere productively.

              1 Reply Last reply
              1
              • Nafab213N Offline
                Nafab213N Offline
                Nafab213
                wrote on last edited by
                #10

                I understood
                For the "Sex Varcher (1)" because I would like to store a single letter in it.
                either M for Male or F for Female.
                It's good as that ?

                For
                                     "Varchar (20),"
                                     "Material (20),"
                It's a mistake I wanted to write
                "matiere Varchar(20), "

                I already corrected in the file.
                Other errors?
                Thank you....

                mrjjM 1 Reply Last reply
                0
                • Nafab213N Nafab213

                  I understood
                  For the "Sex Varcher (1)" because I would like to store a single letter in it.
                  either M for Male or F for Female.
                  It's good as that ?

                  For
                                       "Varchar (20),"
                                       "Material (20),"
                  It's a mistake I wanted to write
                  "matiere Varchar(20), "

                  I already corrected in the file.
                  Other errors?
                  Thank you....

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by mrjj
                  #11

                  @Nafab213
                  Hi
                  For
                  db.setDatabaseName("......"); //Each User give an name at database
                  you can use https://doc.qt.io/qt-5/qinputdialog.html

                   bool ok;
                      QString text = QInputDialog::getText(this, tr("Add New Database"),
                                                           tr("database name:"), QLineEdit::Normal,
                                                           "default", &ok);
                      if (ok && !text.isEmpty())
                          databasename=text; //
                  ....
                  

                  Also this tool is super for inspecting the database and learn about it
                  https://sqlitebrowser.org/

                  JonBJ 1 Reply Last reply
                  2
                  • mrjjM mrjj

                    @Nafab213
                    Hi
                    For
                    db.setDatabaseName("......"); //Each User give an name at database
                    you can use https://doc.qt.io/qt-5/qinputdialog.html

                     bool ok;
                        QString text = QInputDialog::getText(this, tr("Add New Database"),
                                                             tr("database name:"), QLineEdit::Normal,
                                                             "default", &ok);
                        if (ok && !text.isEmpty())
                            databasename=text; //
                    ....
                    

                    Also this tool is super for inspecting the database and learn about it
                    https://sqlitebrowser.org/

                    JonBJ Online
                    JonBJ Online
                    JonB
                    wrote on last edited by JonB
                    #12

                    @mrjj

                    For the "Sex Varcher (1)" because I would like to store a single letter in it.

                    No, because I said you have mis-spelt it. You need to look carefully at how you spell words, that is an extremely common part of programming for which you are really responsible. That's why I said you would really benefit from doing this in an interactive tool, not in code. Please do yourself a favor and download @mrjj 's link to https://sqlitebrowser.org/, believe me it's going to be worth it for you.

                    1 Reply Last reply
                    1
                    • Nafab213N Offline
                      Nafab213N Offline
                      Nafab213
                      wrote on last edited by
                      #13

                      I received your answer and I will read the links afterwards.
                      So for my base ..
                      Do you have any advice to give me on my database?
                      Look at this part of my code ..

                      if(!db.open())
                               {
                                   QMessageBox::critical(0, qApp->tr("Cannot open database"),
                                       qApp->tr("La connexion n'est pas correctement établis à la base de donnée"
                                                "Reprenez le processus.\n\n"
                                                "Cliquer sur annuler pour quitter");
                                    return false ; //i don't know if it's necessary
                               }
                      

                      It's necessary ?
                      Thanks

                      mrjjM 1 Reply Last reply
                      0
                      • Nafab213N Nafab213

                        I received your answer and I will read the links afterwards.
                        So for my base ..
                        Do you have any advice to give me on my database?
                        Look at this part of my code ..

                        if(!db.open())
                                 {
                                     QMessageBox::critical(0, qApp->tr("Cannot open database"),
                                         qApp->tr("La connexion n'est pas correctement établis à la base de donnée"
                                                  "Reprenez le processus.\n\n"
                                                  "Cliquer sur annuler pour quitter");
                                      return false ; //i don't know if it's necessary
                                 }
                        

                        It's necessary ?
                        Thanks

                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #14

                        Hi
                        Yes, good error handling is always needed.
                        But the function it lives in has void as return.

                        void FenCene::newfiledb() // SLot no connected....
                        { ...

                        so it should be just
                        return;

                        1 Reply Last reply
                        1
                        • Nafab213N Offline
                          Nafab213N Offline
                          Nafab213
                          wrote on last edited by
                          #15

                          mrr
                          Excuse me but you talk about
                          "// SLot no connected ...."
                          {...
                          It's just a comment I forgot to take away.
                          Did you read my starting post?
                          Thnks

                          mrjjM 1 Reply Last reply
                          0
                          • Nafab213N Nafab213

                            mrr
                            Excuse me but you talk about
                            "// SLot no connected ...."
                            {...
                            It's just a comment I forgot to take away.
                            Did you read my starting post?
                            Thnks

                            mrjjM Offline
                            mrjjM Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on last edited by
                            #16

                            @Nafab213
                            Hi, i talk about the return statement in

                            if(!db.open())
                                     {
                                         QMessageBox::critical(0, qApp->tr("Cannot open database"),
                                             qApp->tr("La connexion n'est pas correctement établis à la base de donnée"
                                                      "Reprenez le processus.\n\n"
                                                      "Cliquer sur annuler pour quitter");
                                          return false ; //i don't know if it's necessary -> should just be return, since parent function has void as return.
                                     }
                            
                            1 Reply Last reply
                            0
                            • Nafab213N Offline
                              Nafab213N Offline
                              Nafab213
                              wrote on last edited by
                              #17

                              29/5000
                              Thanks mrjj
                              How can I fix that ?

                              Thnks

                              mrjjM 1 Reply Last reply
                              0
                              • Nafab213N Nafab213

                                29/5000
                                Thanks mrjj
                                How can I fix that ?

                                Thnks

                                mrjjM Offline
                                mrjjM Offline
                                mrjj
                                Lifetime Qt Champion
                                wrote on last edited by
                                #18

                                @Nafab213
                                Hi
                                fix ?
                                the return ? just remove false;

                                or do you mean 29/5000 ?

                                Pl45m4P 1 Reply Last reply
                                0
                                • Nafab213N Offline
                                  Nafab213N Offline
                                  Nafab213
                                  wrote on last edited by
                                  #19

                                  When I compile it gives me a lot of error that I do not understand. And I will post the notifications on the forum but before I will correct syntax and vocabulary errors.
                                  Thank you for your help.

                                  1 Reply Last reply
                                  0
                                  • mrjjM mrjj

                                    @Nafab213
                                    Hi
                                    fix ?
                                    the return ? just remove false;

                                    or do you mean 29/5000 ?

                                    Pl45m4P Online
                                    Pl45m4P Online
                                    Pl45m4
                                    wrote on last edited by
                                    #20

                                    @mrjj said in Creation SQLITE database:

                                    @Nafab213

                                    or do you mean 29/5000 ?

                                    I guess 29/5000 is the amount of typed characters in this message :-)


                                    If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                                    ~E. W. Dijkstra

                                    1 Reply Last reply
                                    0

                                    • Login

                                    • Login or register to search.
                                    • First post
                                      Last post
                                    0
                                    • Categories
                                    • Recent
                                    • Tags
                                    • Popular
                                    • Users
                                    • Groups
                                    • Search
                                    • Get Qt Extensions
                                    • Unsolved