Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Developer
Posts: 14
Registered: ‎02-14-2013
My Device: Curve 9320 / 64GB PlayBook
My Carrier: O2 - UK

How can I store data on the same line in an SQLite databasefrom more than one website page?

Having (almost) gotten my head round implementing SQLite in my HTML5 app, I was wondering about how I would go about entering data from more than one webpage into the same line of a given database.

 

Part of the application includes Character Creation forms (spread across three Web pages), and this is where I've started running into problems...

 

I think I have the right code to set up the database and insert the table into it, but when it comes to adding information into a few columns from one line (or updating said data), I haven't a clue...

 

 

Will I have to define a custom function to update just the fields on each page? How would I even do that? ...and how can I check I'm inputting (?) the data into the right line of the table?

 

Thanks in advance,

 

Blackbow 

Highlighted
Developer
Posts: 71
Registered: ‎02-06-2013
My Device: 9900
My Carrier: Rogers

Re: How can I store data on the same line in an SQLite databasefrom more than one website page?

Best practice would be to consolidate all the data and write it to the DB at the same time. You want to keep DB transactions to a minimum as they're expensive.

 

If you don't want to do that, then you at least need a common, unique element from the database to be available on each page.

 

Lets say you had 2 pages (to simplify things).

 

Page one had you entering the following data fields (name, strength)

Page two had you entering the following data fields (name, intellect)

 

Name would be your common, unique identifier use to reference the proper row in the database.

After checking to ensure that the name doesn't exist (and using an INSERT statemebt) your 2 SQL statements would resemble:

"UPDATE tablename SET strength = ? WHERE name = ?"

"UPDATE tablename SET intellect = ? WHERE name = ?"

New Developer
Posts: 14
Registered: ‎02-14-2013
My Device: Curve 9320 / 64GB PlayBook
My Carrier: O2 - UK

Re: How can I store data on the same line in an SQLite databasefrom more than one website page?

@mikefromcanada:

Thanks for your quick reply Smiley Happy

 

If it's better to consolidate the data before writing it, how would I go about this? This is my first app, so I would prefer to learn to do things correctly first time round. Would you be kind enough to provide a code example, please?

 

Thanks in advance

 

Blackbow