Page loading

Share your opinion
What do you think about gambaslinux.fr?
 
Interesting
It miss some informations
Excellent website
Results
WIDGETS GAMBAS
GAMBAS 3 SOFTWARES
TUTORIALS
Library
_gb2.pngDatabase - add,edit,remove

ADD, EDIT, DELETE ITEM IN A DATABASE FILE

 



Today,we learn to use datas in sqlite database with somes gambas 2 sources codes examples.

A) Add data to database

To add data to database, use the CREATE command in your connection :

(Translation french to english : maconnexion=myconnection, matable= mytable, monresultat=myresult)

PUBLIC maconnexion AS new connection
PUBLIC matable AS table
PUBLIC monresultat AS result
PUBLIC sql AS String
maconnexion.type = lower("sqlite3")
maconnexion.host = application.path
maconnexion.name = "mybddFile"
maconnexion.login = ""
maconnexion.password = ""
maconnexion.port = ""
maconnexion.OPEN()
maconnexion.begin
monresultat = maconnexion.create("mytable")
monresultat.update
maconnexion.commit
maconnexion.CLOSE

B) Edit data in database.

I use the EDIT command



DIM maconnexion AS new connection
DIM matable AS table
DIM monresultat AS result
maconnexion.type = lower("sqlite3") 'type de bdd
maconnexion.host = application.path
maconnexion.name = "bdddata"
maconnexion.login = ""
maconnexion.password = ""
maconnexion.port = ""
'ouvre la connexion a la bdd sqlite
maconnexion.OPEN()
monresultat = maconnexion.edit("mytable", "id=" & id)


then EDIT data :

monresultat!monchamp = manouvellevaleur

then update database to save edition:



monresultat.update
maconnexion.commit
maconnexion.CLOSE


3) Delete a line in database.

Same as before but use DELETE command:


monresultat = maconnexion.delete("mytable", "id=" & myid)


Informations:

When you write in your IDE this code :

myconnection. you have help with all possibles commands as this :


 

mabdd0.png mabdd1.png
mabdd2.png mabdd3.png




Look at documentation for help , this is very interesting.
Thanks for your attention.
Regards


Creation date : 20/03/2012 @ 07:12
Last update : 20/03/2012 @ 19:09
Category : Database
Page read 4540 times


Print the article Print the article


react.gifReactions to this article

Nobody gave a comment yet.
Be the first one to do it!


QUICK MENU
SEARCH




LANGUAGE
COMPONENTS
Other
LANGUAGE
Where, who?
VISITS

   visitors

   visitors online

ARCHIVES GAMBAS 1/2
^ Top ^