Results 1 to 5 of 5

Thread: database_qml

  1. #1
    Join Date
    Nov 2011
    Location
    coimbatore
    Posts
    80
    Thanks
    1
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default database_qml

    anyone please help me,
    i can't retrieve my data from qml database here is my code,

    // import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
    import QtQuick 1.1
    import "storage.js" as Storage

    Rectangle {
    width: 1200
    height: 700
    color:"white"
    TextInput
    {
    id: userInput
    width: parent.width-6
    height: parent.height-6
    anchors.centerIn: parent
    font.pixelSize: 20
    font.bold: true
    maximumLength: 15
    color: "red"
    text: ""

    }


    Rectangle{

    id:button
    width: 100
    height:50
    color: "green"
    x:100
    y:100
    MouseArea

    {

    id:save
    anchors.fill: parent
    onClicked:{
    // rectangle1.width = (rectangle1.width+25);
    Storage.getDatabase(userInput.text);
    // rectangle1.findScores(userInput.text);

    }
    }


    }



    Rectangle{

    id:button12
    width: 500
    height:50
    color: "green"
    x:150
    y:150

    TextInput
    {
    id: qwet
    width: parent.width
    height: parent.height
    x:150
    y:150
    anchors.centerIn: parent
    font.pixelSize: 20
    font.bold: true
    maximumLength: 15
    color: "red"
    text:'' ''

    }


    MouseArea

    {

    id:save123
    anchors.fill: parent
    onClicked:{
    // qwet.text= ; //this line i want get my data please tell me how to retrieve

    }

    }


    }



    }

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: database_qml

    Bearing the fact we don't know what is the content of "storage.js", there is no way we can help you.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2012
    Location
    Iran, Tehran
    Posts
    308
    Thanks
    75
    Thanked 24 Times in 21 Posts
    Qt products
    Qt4 Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Re: database_qml

    Please use tags to show your codes =>

  4. #4
    Join Date
    Nov 2011
    Location
    coimbatore
    Posts
    80
    Thanks
    1
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: database_qml

    thanks for your reply,

    this is my database javascript code ....please help me.....







    //storage.js
    // First, let's create a short helper function to get the database connection
    function getDatabase() {
    return openDatabaseSync("MyAppName", "1.0", "StorageDatabase", 100000);



    }

    // At the start of the application, we can initialize the tables we need if they haven't been created yet
    function initialize() {
    var db = getDatabase();

    db.transaction(
    function(tx) {
    // Create the settings table if it doesn't already exist
    // If the table exists, this is skipped
    tx.executeSql('CREATE TABLE IF NOT EXISTS settings(setting TEXT UNIQUE, value TEXT,value2 TEXT,value3 TEXT,value4 TEXT,value TEXT)');
    });
    }

    // This function is used to write a setting into the database
    function setSetting(setting, value) {
    // setting: string representing the setting name (eg: “username”)
    // value: string representing the value of the setting (eg: “myUsername”)
    var db = getDatabase();
    var res = "";
    db.transaction(function(tx) {
    var rs = tx.executeSql('INSERT OR REPLACE INTO settings VALUES (?,?);', [setting,value]);



    //console.log(rs.rowsAffected)
    if (rs.rowsAffected > 0) {
    res = "OK";
    } else {
    res = "Error";
    }


    }

    );
    // The function returns “OK” if it was successful, or “Error” if it wasn't
    return res;
    }
    // This function is used to retrieve a setting from the database
    function getSetting(setting) {
    var db = getDatabase();
    var res="";
    db.transaction(function(tx) {
    var rs = tx.executeSql('SELECT * FROM settings WHERE setting=?;', [setting]);
    if (rs.rows.length > 0) {
    res = rs.rows.item(0).value;
    } else {
    res = "Unknown";
    }
    })
    // The function returns “Unknown” if the setting was not found in the database
    // For more advanced projects, this should probably be handled through error codes
    return res
    }

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: database_qml

    And what exactly do you expect us to do now? How should we know what you want to retrieve from the database?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.