HTML5 Web SQL Database program

This article describe HTML5 Web SQL Database program.
  • 2810

HTML5 Web SQL Database program

The below declared program is the final program of HTML5 SQL Database, in this program all  code are written which perform operation for example code of opendatabase, insert ,execute ,read etc

 Example:

<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
var dab = openDatabase('empdb', '1.0', 'test DB', 2 * 1024 * 2048);
var masg;
dab.transaction(function (txt) {
txt.executeSql('CREATE TABLE IF NOT EXISTS LOGIN (id unique, logs)');
txt.executeSql('INSERT INTO LOGIN (id, logs) VALUES (1, "amrit")');
txt.executeSql('INSERT INTO LOGIN (id, logs) VALUES (2, "loginmessage")');
txt.executeSql('INSERT INTO LOGIN (id, logs) VALUES (3, "my message")');
masg = '<p>LOGIN message created and row inserted.</p>';
document.querySelector('#status').innerHTML = masg;
});
dab.transaction(function (txt) {
txt.executeSql('SELECT * FROM LOGIN', [], function (txt, results) {
var leng = results.rows.length, i;
masg = "<p>Found rows: " + leng + "</p>";
document.querySelector('#status').innerHTML += masg;
for (i = 0; i < leng; i++){
masg = "<p>your message is= &nbsp<b>" + results.rows.item(i).logs +"</b> &nbsp AND ID=&nbsp <b>" +results.rows.item(i).id + "</b></p>";
document.querySelector('#status').innerHTML += masg;
}
}, null);
});
</script>
</head>
<body>
<div id="status" name="status">Status Message</div>
</body>
</html>

Note: This is a program that produce the output

OUTPUT

pic.jpg

Further Readings

You may also want to read these related articles :

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2019 DotNetHeaven. All rights reserved.