CRUD SQLite example

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

jesse
Posts: 205
Joined: Thu Nov 11, 2010 6:32 pm

Re: CRUD SQLite example

Post by jesse »

Thanks for the update. Still I have no clue why when I compile as a standalone none of the buttons that are supposed to manipulate the datagrid are working.
I tried clear datagrid, and read into datagrid but nothing changes on the datagrid. Of course everything works fine while in development mode.

Any ideas?
Deving on WinVista Home Prem. SP2 32 bit. Using LiveCode 4.6.1 Pro Build 1392
townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Re: CRUD SQLite example

Post by townsend »

I didn't even think to create a Standalone. You're right. The DtataGrid was frozen.
I tried everything I could think of. Nothing worked. So, I just deleted the DataGrid
and created a new one, with the same name. Works good now.
102 CRUD SQLite example 3.5.JPG
102 CRUD SQLite example 3.5.JPG (54.63 KiB) Viewed 26209 times
Attachments
CRUD_SQLite_example_v3.5.zip
(8.89 KiB) Downloaded 1301 times
jesse
Posts: 205
Joined: Thu Nov 11, 2010 6:32 pm

Re: CRUD SQLite example

Post by jesse »

That is very odd. I used your CRUD script as a starting point for my script and had the same problem with the datagrid
not working. Sure enough like you mentioned I deleted the grid and re-created it and it works now. If you happen to find
out what the issue was please let me know as I can't figure it out for the life of me. Thanks again for your help!
Deving on WinVista Home Prem. SP2 32 bit. Using LiveCode 4.6.1 Pro Build 1392
townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Re: CRUD SQLite example

Post by townsend »

did you update the download on the other post? i would love to download
it once its updated. its really helped me to understand how to do things more.
Okay-- Here's the updated version, with the dynamic column names.
103 CRUD SQLite example 3.6.JPG
103 CRUD SQLite example 3.6.JPG (60.74 KiB) Viewed 26232 times
Attachments
CRUD_SQLite_example_v3.6.zip
(9.47 KiB) Downloaded 1306 times
BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: CRUD SQLite example

Post by BvG »

Hi

please make a presentation on livecode.tv about the sql example stack, it's so grand! Please contact me at bvg AT mac DOT com.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3582
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: CRUD SQLite example

Post by mwieder »

Oooo - I second that - this would make a great presentation for livecode.tv
townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Re: CRUD SQLite example

Post by townsend »

Thanks for the encouragement guys!
Yeah-- sure-- I'd be glad to do a presentation for livecode.tv
after I finish at the Summer Academy. (3 weeks left)
There's not much to the example. If I ALSO went over the basics of
the SQL manager, SQLiteMan, then I probably could do 20-30 minutes.

BvG-- I'll send you an email about this. Also, I've been trying to
log into RevOnline for days now. It looks like they're not accepting
uploads right now.
townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Re: CRUD SQLite example

Post by townsend »

I finally finished this SQlite database example. It's chock full of tight,
good-as-can-be code. I wrote it to be my own personal reference,
but I'm sure other LiveCode beginners will find a lot good code here,
to cut and paste into your own application. Maybe save some time,
instead of trying to figure this stuff out from scratch.
108 CRUD SQLite example 4.3.JPG
I've added new Buttons and Handlers to the main Stack.

AND created a new Sub-Stack called Preferences. This is a single
function called dbData-- that you can use-- to easily save and retrieve
any value in your application, including entire DataGrids. As a single
function, you can simply copy and paste the whole thing into any application.

It's clean, well commented code. Also as is often the case when coding,
we must choose between better efficiency or better readability.
I always opt for better readability and ease of maintenance,
especially in a compiled environment like LiveCode.
Attachments
CRUD_SQLite_example_v4.3.zip
(11.26 KiB) Downloaded 2257 times
jesse
Posts: 205
Joined: Thu Nov 11, 2010 6:32 pm

Re: CRUD SQLite example

Post by jesse »

Great job! Only problem I see so far is when I try to edit a row and click the update button it says updated but when i refresh the grid the row is not
updated anymore. am i missing something?

also just a silly spelling error but the comment "row in table control updated sussefully" should be successfully of course.
Deving on WinVista Home Prem. SP2 32 bit. Using LiveCode 4.6.1 Pro Build 1392
townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Re: CRUD SQLite example

Post by townsend »

Got that typo corrected-- but the Update Row seems to work okay.

First highlight a Row, then press the Update button.

Refresh, brings it back fine over here.

Anyone else having this problem?
townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Re: CRUD SQLite example

Post by townsend »

I found more typos. The name Entry was originally Value, but was changed to
avoid confusion with the SQL keyword VALUE. These are the corrected Usage
Instructions for the dbData function.
This Stack contains a single funcion, which Inserts, Updates,
and Reads rows in a SQLIte file called, System.data.
Usage: dbData (Handle, Entry)
If 'Handle' already exists 'Entry' is Updated instead of Inserted.
Null in 'Handle' closes connection.
Null in 'Entry' returns retrieved Entry.
Successful Inserts & Updates return 'ok'.
Any errors, return details, prefixed with the word, 'ERROR'.
If you use this stack, just paste them into the Contents of the Display field.
paul_gr
Posts: 319
Joined: Fri Dec 08, 2006 7:38 pm

Re: CRUD SQLite example

Post by paul_gr »

Thanks Townsend,
useful example -- it's appreciated.

Paul
townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Re: CRUD SQLite example

Post by townsend »

This weekend I did a short presentation going over this CRUD SQLite Example.

Here's the link to the video: http://dl.dropbox.com/u/35256958/CRUD-Example-video.mp4
(Note: this link should be good until the end of the month. Aug-2011.)

Also here's a minor update.Version 4.4.
Attachments
CRUD_SQLite_example_v4.4.zip
(11.81 KiB) Downloaded 1775 times
BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: CRUD SQLite example

Post by BarrySumpter »

Nice!
Great work on the video!
And thanks for the update!
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.
BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: CRUD SQLite example

Post by BvG »

The video is also available from the livecode.tv site:

http://blog.livecode.tv/2011/08/event-35-wrap-up/
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
Post Reply