-
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
}
}
}
}
-
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.
-
Re: database_qml
Please use tags to show your codes =>
-
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
}
-
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?