Creation of SQLITE InsertQuery

IAM trying to do a generic function to insert data to the specified table. What I have done until now is the following:

Intialise()
{
   QVariantMap parametersMap;   //Assuming that Data to insert will be received as QVarient map from server.So I just added the record data to a QvarientMap

  parametersMap["title"] = "Titl1_";
  parametersMap["titleArabic"] = "tille_Arabic";  

  const  QString &value1 = parametersMap.value("title").toString();
  const QString &value2 = parametersMap.value("titleArabic").toString();

  QString insertQuery =  ("INSERT INTO customer (title, titleArabic) VALUES(:value1 ,:value2)");
   dbHelp.InsertRecord(insertQuery,parametersMap);

}

In DbHelper class I have the function to insert data 

void dbHelper::InsertRecord(const QString Insertquery, QVariantMap parameterMap)
{
        QSqlDatabase database = QSqlDatabase::database();
        QSqlQuery query(database);
        query.prepare(Insertquery);
       const  QString &value1 = parameterMap.value("title").toString();
       const QString &value2 = parameterMap.value("titleArabic").toString();

        query.bindValue(":value1",value1);
        query.bindValue(":value2", value2);
        query.exec();

        if( query.exec())
          {
           alert(tr("Record created"));
          }
        else
         {
            const QSqlError error = query.lastError();
            alert(tr("Create record error: %1").arg(error.text()));
         }
    database.close();
}

As Iam using variable value1 and value2 as values Records to insert Iam not able to include these variables directly in the query

What I do is the function insertREcord Iam binds the variable with the value. For this reason, I can't do the generic function

MyQuestion is:

) s it possible to add the variable itself as a value to be inserted into the query. So that it is not necessary to bind the variable

I found the solution,

I tried this query

("INSERT INTO customer (title, titleArabic) VALUES (------" "value1 +"-",-" "Value2 +" \ ")" ");

Tags: BlackBerry Developers

Similar Questions

  • The synchronized application: creation of menu items for each call to makeMenu SQLite?

    A matter of design, which is a good implementation of the following?

    My requirements are:

    1. Have a different menu for each screen.
    2. The battery of the screen will be high both a single screen.
    3. To switch screens, the user must use the menu.

    I created the menu for each screen by the following:

    protected void makeMenu(Menu menu, int instance) {
    super.makeMenu(menu, instance);
    Database db = null;
    try {
    
      db = ResourceManager.getConnection(true);
      mCoffeeDao = new FlavshellDao();
      mTabDao = new FlavmDao();
    
      if (instance == Menu.INSTANCE_CONTEXT) {
          Bitmap logoWbg = Bitmap.getBitmapResource(resource
                  .getString(ScoreCenterResource.logo));
          Image image = ImageFactory.createImage(logoWbg);
    
          gMenu.setIcon(image);
          nMenu.setIcon(image);
          aMenu.setIcon(image);
          shMenu.setIcon(image);
          avMenu.setIcon(image);
          logoMenu.setIcon(image);
    
          menu.add(gMenu);
          menu.add(nMenu);
          menu.add(aMenu);
          menu.add(shMenu);
          menu.add(avMenu);
          menu.add(logoMenu);
      }
    
      if (instance == Menu.INSTANCE_DEFAULT) {
          menu.add(logMenu);
          menu.add(exitMenu);
    
          shell = mCoffeeDao.findAll();
    
          for (int i = 0; i < shell.length; i++) {
              Flavshell m = shell[i];
              /**
               * Ordering parameter, lower values are placed closer to the
               * top of the menu screen.
               */
              item = new FlavMenuItem(m.getPk(), m.getFlavortitle(),
                      200 + i);
              menu.add(item);
          }
    
          String[] params = {
              Integer.toString(this.mCoffeePk)
          };
          Flavm[] m = mTabDao.findByDynamicWhere("FLAVOR = ?",
                  params);
    
          if (m.length > 0) {
              for (int j = 0; j < m.length; j++) {
                  if (m[j] != null) {
                      Flavm specificMenu = m[j];
                      item = new FlavMenuItem(specificMenu.getPk(),
                              specificMenu.getTitle(), 100 + j);
                      menu.add(item);
                  }
              }
    
              menu.add(MenuItem.separator(105));
          }
      }
    
    } catch (FlavshellDaoException e) {
      Logger.logEventError(e.getMessage());
    
    } catch (FlavmDaoException e) {
      Logger.logEventError(e.getMessage());
    
    } finally {
      try {
          db.close();
      } catch (DatabaseException e) {
          Logger.logEventError("Menu Database error: " + e);
      }
    }
    

    I created a database with a single link object read in the following text:

    public synchronized static final Database getConnection(
        final boolean readOnly) {
    Database db = null;
    try {
        URI userFileURL = URI.create(System
                .getProperty("fileconn.dir.memorycard")
                + resource.getString(CoffeeHouseResource.db_path)
                + resource.getString(CoffeeHouseResource.db_name));
    
        db = DatabaseFactory.open(userFileURL, readOnly);
    
    } catch (MalformedURIException e) {
        Logger.logError("Get connection: URI: " + e.getMessage());
    } catch (ControlledAccessException e) {
        Logger.logError("Get connection: Controlled Access: "
                + e.getMessage());
    } catch (DatabasePathException e) {
        Logger.logError("Get connection: Database Path: "
                + e.getMessage());
    } catch (DatabaseIOException e) {
        Logger.logError("Get connection: Database IO: "
                + e.getMessage());
    } catch (Exception e) {
        Logger.logError(e.getMessage());
    }
    return db;
    }
    

    My question is,

    • If the user to call the menu as happening in any other activity database (SQLite), making the synchronized method will prevent database locks?
    • Should I design my makeMenu got a call from the database at all? It seems to me that all this works, this could potentially cause a lot of traffic on the SQLite database?
    • I thought to move the menu to a vector and storing the menu in storage Runtime, but I read that the Runtime Storage has the memory leak issues?

    Your basic design principles seem well - I have a number of applications that actually have "tabs" screens, so clicking on a tab or using the menu swaps from one screen to the other.  You can just push the new screen and pop, that. In fact, here's a menu from a screen, that I am currently working:

    _StatsMenu MenuItem = new MenuItem ("Stats", 110, 10) {}
    public void run() {}
    UiApplication.getUiApplication () .pushScreen (new StatsScreen (System.currentTimeMillis (), 0));
    UiApplication.getUiApplication () .popScreen (BaseScreenWithToolBar.this);
    }
    };

    While I haven't looked in detail, but your code dangerous look.

    I've never tested, but I suspect makeMenu is called using the EventThread.  Doing things like database connections in this method will cause you problems.  Do not.  If you need to query the database, do so before makeMenu is called.  Starts a separate Thread and set the appropriate menus if this Thread is not finished.  or block the user interface, until he made.

    In addition, I wouldn't do it in makeMenu:

    Bitmap logoWbg = Bitmap.getBitmapResource (resource
    .getString (ScoreCenterResource.logo));
    Image image = ImageFactory.createImage (logoWbg);

    You can do it once to the creation of the screen, or better yet, once at startup and save it in a shared domain.

    If you do not want to create a dynamic menu, then use the normal persistent store - or check out the details for the database once at startup and use them after that RAM.

    And avoid lifting heavy objects in makeMenu.

    I hope this helps.

  • What is a good implementation of creation from records in a database SQLite MenuItems?

    From my understanding and reading of the API MenuItem KB, I need to extend the class MenuItem for each menu item that I want to create.

     ...
        // setup the menu items
        MenuItem item = new MyMenuItem();
        menu.addItem(item);
        ...
        class MyMenuItem extends MenuItem {
            MyMenuItem() {
                super(MyResourceBundle.getBundle(), MyResource.MY_MENU_ITEM, 0, 100);
            }
            public void run() {
                // do something
            }
        }
    

    I returned a list of five to eight records to a SQLite database, and I want to as the label of each record (String) to be a label for the menu item.

    Do I just loop through the records and create a MenuItem for each record and add the menu item to the menu in the loop?

    {for(each record)}

    create MenuItem

    Add MenuItem to the menu

    }

    Or is he a good implementation for this?

    Thank you

    Slight variation:

    class MyMenuItem extends MenuItem {}
    MyMenuItem (String menuLabel) {}
    Super (menuLabel, 0, 100);
    }
    public void run() {}
    do something
    }
    }

    {for(each record)}

    excerpt from label

    create MenuItem (label)

    Add MenuItem to the menu

    }

  • SQLite DB in 10 bb

    IAM, develop an application with SQlite as db. Is this possible in bb 10 waterfalls. I have found no useful link where I can start with Sqlite db creation. (Create db tables, how to get data from db, how to set the db data). Can someone help me please

    Yes, SQLite is used in this sample. This sample create db before and copy in the data folder.
    If you want to create the table during execution, you can use this

    https://developer.BlackBerry.com/Cascades/reference/bb__data__sqlconnection.html

    When your application startup is called

    https://developer.BlackBerry.com/Cascades/reference/bb__data__sqlconnection.html#function-execute-Qu...

    It seems that QtSql can help you, too

    https://developer.BlackBerry.com/Cascades/reference/QtSql.html

  • Read a file external .sqlite in WebWorks

    Hello!

    I am developing an app for BB10; I have a .sqlite file that is generated by a software and I want to do some queries about it.

    I read that I can't rely on the HTML5 database because it only allows you to use an arbitrary .sqlite file, but only on those integrated in webworks.  Is this correct?

    Is it possible to read data from my WebWorks .sqlite file?

    Yes, this is not a restriction of WebWorks so as a restriction of security itself imposed by browser based environment. The Web mode, you cannot load a sqlite arbritray. Or at least as far as I know.

    The simplest method is, perhaps, do the following:

    1. gather or load database as a drop of the database of SQL commands.

    2 loop on the loaded file and run commands on the database WebSQLite insertion and the creation of all the tables you need to load/runtime.

    3 queries you would like your information.

  • Disappeared on update SQLite database

    Hi all

    I just submitted an update of my application that uses a SQLite database.  In the update, I changed the table creation code and removed one of the columns of the table.  Nothing else has been changed with the code base.  And I still have the clause "if not exists" in the create table sql statement.  BB has approved my application and I downloaded the version on my PB noticed two horrible things.

    First of all, I have now two icons on my homescreen with the same name.

    Secondly, when I start the new version, nothing in my database.  It seems to create a new as if the other did not exist.  I went back to my source code and I tried to create two tables with the same name and reinsert the old column that I had deleted, but as I had suspected, the program threw a "table already exists error" when I tried to run the second create statement.

    Have I missed something obvious with SQLite databases?

    Also, I changed the minimum required version of Tablet OS to 1.0.6 requirement of 1.0 for my application.  Would this have something to do with the duplication?

    When you test this point until I published, there was no duplication and my SQLite data are not allowed.  I since temporarily withdrew my application of the sale.

    Thank you very much all the advice.

    As John said, you have changed your application somehow signature, so that it shows up as a brand new application.  It is usually because you asked new signature keys, but it can also occur if you have changed the package of your application, or possibly other ways id.

    Moreover, there is no way to actually remove a column in SQLite, so what you try to do it very probably won't work anyway.

    The table creation code is executed only once.  After that, the table exists and you can't run again. There are some statements like 'ALTER TABLE ADD COLUMN xxx foo' that could add a column, with some restrictions, but there is no equivalent 'DELETE a COLUMN '.  The only way to do that is to create a temporary table with the missing column, copy the data from the old to the new table, DELETE the old table, then rename the temporary to the old name.

    Often, you may be better to do something as affecting only the old NULL column (if you have authorized that) or just ignore him.

    In the future, always test thoroughly using the version signed by your application, just prior to submission.  Make sure you have the previous signed version installed first, so that you can simulate the "update" to the new, but also test with no previous version installed.  You should be able to observe the same behavior that users see by doing this.

  • Video metadata date is incorrect: the value and not of creation date sharing

    10 iOS, iPhone 6 +, Windows 10. Photos and videos are shared through iCloud, but NOT stored in iCloud.

    Once synced on my PC, the photos and videos have a truncated name (for example, "016a1f2e11dfcc680e1009cb96346b67678fb2c6bc.jpg"). Of course, this is not acceptable at all to me when I organize them on my NAS: I prefer a significant, sortable name, as "2016-09-16 18-15-20259 (Apple iPhone 6 more) .jpg.

    To do this, I simply read the EXIF information directly from the image, and I rename the image accordingly. No problem for the photos.

    But for videos... I do the same, in the world, but with less information. I can extract only creation date/time from metadata of the videos, not the unit that captured video. Sad, but I have not found anything else, and at least it's automatic.

    Recently, I found that the date in the video file is NOT correct: this is the timecode of SHARING via iCloud, not the timecode CAPTURE. I have therefore some videos with a delta of two weeks between the true creation as well as the "official" date

    I checked this on my phone: date is correct (once the video is no longer in full screen, the date is displayed at the top of the screen, and it is 'the' date I'm looking).

    So, question: How can I get the date of the 'real' creation of all these videos on my PC? It exists: it appears on the iPhone that took the video (a woman) AND mine. Information is 'lost' only on the PC, but I think it's a problem of reading of 'bad' metadata (I use FFMPEG to get currently), or the wrong file for reading (perhaps within an iTunes/database file, but didn't find, not found in the registry or the other).

    Best solution is to find something operate locally, through the command line, to do it in batch mode. A solution of GUI PEUT agree if I can automate with AutoIt (i.e. should not be a native Win32 application, not Java, .NET, GTK, QT and so on, OR must have an export feature). A solution based on the web is not suitable, but can be less boring to review each video one after another to manually check the date.

    Thanks in advance.

    In my opinion, the only way to fix this is with third-party software like this one.

  • Disabling creation tag 'Album fate. "

    Hello - the first time poster.

    Since the upgrade to iTunes 12.4.3.1 under Windows, I noticed that when filling tags for titles in my playlist ID - for example, update of the artist, Album and work - a new tag "Album fate" is created.

    Is there a way to disable the creation and filling of this tag 'Album fate? "  I'm certainly very finnicky to keep my ID tags clear of unwanted information, and the tag of the Album sorting is not something I'm curious about.  Of course, I can manually remove the tags later outside of iTunes, but it would be better, if they were not created in the first place.

    Thoughts?  Thanks in advance for any guidance, much appreciated!

    cbal324

    Since the upgrade to iTunes 12.4.3.1 under Windows, I noticed that when filling tags for titles in my playlist ID - for example, update of the artist, Album and work - a new tag "Album fate" is created.

    Hello Cbal,

    iTunes does not automatically create an Album tag kind.  It seems that as it does.

    From 12.4, if the tag Album sorting is not met, iTunes will display the name of the Album in the Album sort field (less 'a', 'one', or 'the' in the English version).  It shows in grey to indicate that it is not really met.  This is to show how the album will sort.

  • How to find the SQLite database browser on an imac

    Where is the SQLite database browser on an iMac?

    Here, you can get a http://sqlitebrowser.org/

  • URL bar autocomplete works not, renamed file: places.sqlite, now impossible to restore or import bookmarks

    AutoComplete in the bar of my url suddenly stopped working. I use Firefox on a Mac with OS 10.10.5 43.0. First of all, I checked that AutoComplete is enabled in the preferences, "refreshed" Firefox and install a new copy. When none of that worked, I changed the name of the places.sqlite file in my folder of profile, as shown in this thread: https://support.mozilla.org/en-US/questions/951168. It worked and now the url bar autocompletes; Hooray!

    But now my favorites are gone! I supported manually to the top of my favorites in advance, as .html and .json, but when I try to restore/import my favorites of these files, it does not work: I find myself with a bunch of empty folders. Help?

    If you open the HTML export file in a Firefox tab as a web page, should your bookmarks? In other words, is this a problem of import, or was it a problem of export?

  • Cannot find the overall messages file - db.sqlite

    Hi, volunteers! Thank you for being here.

    The search function of Thunderbird has stopped working. He cannot find all - regardless of the query returned no results.

    I understand that I need to rebuild the global database to correct this and have read the instructions here:

    https://support.Mozilla.org/en-us/KB/rebuilding-global-database

    He tells me to delete my profile from TB global-messages - db.sqlite. Connects me to another page on how to find this profile. I followed these instructions:

    "How to find your profile.

       Click on the menu button or menu bar.
       From the Help menu, click Troubleshooting Information.
       In the Application Basics section, Profile Folder, click on Show in Finder.
       The Mac Finder window will show the name of the profile as well as the path to it."
    

    The finder window shows me this file: zfrnv9to.default - 1445806062498. Nothing inside it looks like the file I'm supposed to delete, which is global-messages - db.sqlite.

    I also used the Mac projector for a search on "global-messages - db.sqlite. He cannot find anything like this on my Mac Air (which is running El Capitan). It is usually pretty reliable to dig up files, but - no luck.

    What should I do now?

    Zenos, thank you! I solved this on my own last night.

    In case it helps the next person: I re-read the page of Mozilla to find the file.

    So, rather than looking in the Application databases, I dug through my files user myself, using the information that it would be under User/Library etc.

    It took a few minutes of poking around to find it. I deleted it, restarted TB, and the search function is back.

    The mystery that I can't solve it is why the recommended method or research Spotlight of the CMA does not find it in the first place. But with time and patience, the manual search does the job.

    Thanks for the tips, the time and help!

  • Regarding the functions of profile file (permissions.sqlite etc..)

    http://KB.mozillazine.org/Profile_folder_-_Firefox

    Permissions.SQLite

    reading - list.sqlite

    Search - metadata.json

    Times.JSON

    Now I know most of them is explained in the article linked above, but not all. I was wondering if anyone knows what each of them and what are the effects of delete them in the process. Since Firefox will delete obsolete/replaced not by / replaced files, I have to do it manually to clean bloating with some versions. That some of them have not been updated in a while or if I have a question its current position to keep it in the folder.

    Research - metadata.json stores data for the search engine as a key word (alias), their order and if they are enabled.

    You can open JSON files in Notepad (Firefox Tools menu button > Web Developer) for the purpose of inspection.
    Click on the button to "Pretty Print" to fit the file for readability.

    You can use the SQLite Manager extension in Firefox to inspect the SQLite database files.

    Permissions.SQLite stores the specific site (site preferences) permissions as you can see by his name.

    You can control and manage permissions for the domain in the tab currently selected through these steps:

    • Click the address bar onthe Site identity button"(globe/lock)
    • Click on 'More information' to open ' tools > Page Info "with the Security tab is selected

    Go to the permissions tab (Tools > Page Info > permissions) to check the permissions for the domain in the currently selected tab.

  • Local error-1200 creation push certificates on the server. Any idea?

    In the Application Server

    When you try to renew or create a certificate to push comes up with the error "Certificates to push creation local error - 1200" on the server. Any idea? »

    I'm having the same problem with 10.7.5 server. (two of them)

    At the time of renewal, I was looking at the Console and I think the Apple Server SSL certificate is therefore more reliable.

    (or server versions are low)

    August 15 at 10:23:08 login.* * servermgrd [23349]: received the connection error: error domain = NSURLErrorDomain Code =-1200 "error SSL and a connection to the server cannot be made. UserInfo = 0x7fb8f5aab9a0 {NSUnderlyingError = 0x7fb8f15af450 "error SSL and a connection to the server cannot be made.", NSErrorFailingURLStringKey =https://identity.apple.com/pushcert/caservice/renew, NSErrorFailingURLKey =https://identity.apple.com/pushcert/caservice/renew, NSLocalizedRecoverySuggestion = you want to connect to the server anyway?, NSLocalizedDescription = SSL an error has occurred and a connection to the server cannot be made.}

    August 15 at 10:23:08 login.* * servermgrd [23349]: certificate request to push failed: reason = Local, error code = - 1200, error = error Domain = NSURLErrorDomain Code =-1200 "error SSL and a connection to the server cannot be made. UserInfo = 0x7fb8f5aab9a0 {NSUnderlyingError = 0x7fb8f15af450 "error SSL and a connection to the server cannot be made.", NSErrorFailingURLStringKey =https://identity.apple.com/pushcert/caservice/renew, NSErrorFailingURLKey =https://identity.apple.com/pushcert/caservice/renew, NSLocalizedRecoverySuggestion = you want to connect to the server anyway?, NSLocalizedDescription = SSL an error has occurred and a connection to the server cannot be made.}

    So not yet an idea, but hopefully with these console outputs happen to something?

  • How to get the creation Date of the site recorded for the footer output (printing to PDF)?

    If you go to Page Setup in Firefox, the option for the footer is the date and/or time of output. I don't want today's date that its print, but would rather than the Date of the creation of this web session saved as it is important to display this information with a legal matter. The research that has been done on a computer is out of date of creation down instead. I know that I could add the date by using the custom field for a footer in the Page options but prefer automated sound somehow when you print to a PDF (CutePDF). Please let me know.

    Thank you

    You might be able to automate this process if you open your PDFs with Adobe Acrobat Pro and make sure that the PDF file has a date of receipt:
    Idea of *http://smallbusiness.chron.com/print-date-time-stamps-pdf-55986.htm...

  • How can I import my old passwords of key3.db key3 and files for the new firefox signons.sqlite 41.0?

    I recently updated my PC and my old hard drive in system is placed as a slave in my new PC. Seen key3 and signons.sqlite key3.db files of the old firefox, how to import passwords saved in the new firefox 41.0?

    Thank you.

    How old was the older Firefox? Firefox 33 and then use this pair of files:

    • logins. JSON -. saved passwords.
    • signons3.txt - this file stores your database key for your passwords.

    If you want to move the old in your current profile (to replace new empty files for the most part), this is the fastest way to open your folder of the currently active profile. Either:

    • button "3-bar" menu > "?" button > troubleshooting information
    • (menu bar) Help > troubleshooting information
    • type or paste everything: in the address bar and press Enter

    In the first table of the page, click on the view file"" button. This should launch a new window that lists the various files and folders in Windows Explorer.

    Leave this window open, switch back to Firefox and output, either:

    • "3-bar" menu button > button "power".
    • (menu bar) File > Exit

    Pause while Firefox finishing its cleanup, then rename logins.json to something like logins.old and key3db to something like key3.old.

    Now copy the old two files in this folder.

    Launch Firefox back up again. These connections are available?

Maybe you are looking for