You are on page 1of 9

EX.

NO: DATE : AIM:

GAMBAS

To work with the components in GAMBAS in order to establish the database connectivity and access the database by inserting records. STEPS INVOLVED: STEP:1 - Open Gambas and click New ro!ect STEP:2 - Select Graphical ro!ect

STEP:3 -Give the name and title o" the ro!ect and select the location to save the pro!ect.

STEP:4 -#rom the Tree view in the ro!ect $%plorer & yo' will see the items listed as "ollows( )lasses #orms Mod'les *ata

STEP:5 -)reate a "orm in #Main 'sing the Tool bo% .

To Create a new M S!L Conne"t#on: STEP:1 - Be"ore yo' contin'e& make s're the "ollowing components are selected on yo'r pro!ect( gb.db *atabase Access gb.db.mys+l MyS,- *atabase driver gb.db.odbc O*B) *atabase driver STEP:2 - To enable the components& go to ro!ect . roperties and click )omponent tab STEP:3 - check the "ollowing components /. gb - 0nternal native classes 1. gb.db - *atabase access 2.gb.db."orm - *ata bo'nd )ontrols 3. gb.db.mys+l - MyS,- *atabase *river 4. gb.db.odbc - O*B) database driver STEP:4 $ Now )reate a new mod'le. 5ight click on #orm and select New Mod'le. Give a name to yo'r new mod'le( 6 name is cse in this pro!ect 7 STEP:5 - 8ere is the content o" the mod'le 6 cse.mod'le 7( 9B-0) con AS N$: )onnection 9B-0) 5O)$*95$ )onnect67 con.)lose67 con.Type ; <MyS,-= con.8ost ; <localhost= con.-ogin ; <root= con. assword ; <oslabic= con.Name ; <gambas= con. ort ; <22>?= con.Open67

$N*

STEP:% - Then yo' can call the mod'le on yo'r "orm or program to start or open the MyS,- )onnection 'sing the code below& 9B-0) S9B btnopencon@)lick67 mys+lcon.)onnect67 Message.0n"o6<)onnection opened=7 $N* Ao' can r'n the program to start or open the MyS,- connection by clicking on /7 5OB$)T -C compile 17 *$G9G-C r'n

Co&e 'or t(e 'or) #n *Ma#n."+a,, are : #O5 D0$: B9TTON( 9B-0) S9B B'tton/@)lick67 *0M rs AS 5es'lt *0M rowno AS 0nteger ; > *0M + AS String + ; Eselect F "rom st'dentE rs ; cse.con/.$G$)6+7 GridDiew/.8eader ; GridDiew.8oriHontal GridDiew/.Grid ; T59$ GridDiew/.5ows.)o'nt ; /> GridDiew/.)ol'mns.)o'nt ; /> GridDiew/.)ol'mnsI>J.Te%t ; E0*E GridDiew/.)ol'mnsI/J.Te%t ; ENAM$E GridDiew/.)ol'mnsI>J.:idth ; />> GridDiew/.)ol'mnsI/J.:idth ; />> 0# rs.available T8$N rs.movene%t GridDiew/.5ows.)o'nt ; rs.)o'nt #O5 $A)8 rs GridDiew/Irowno& >J.Te%t ; rsKid

GridDiew/Irowno& /J.Te%t ; rsKname 0N) rowno N$GT $-S$ Message.0n"o6Erecord not "o'ndE7 $N*0# cse.con/.)ommit67 $N* #O5 0NS$5T B9TTON ( 9B-0) S9B B'tton1@)lick67 *0M rs AS 5es'lt cse.con/.Begin67 rs ; cse.con/.)reate6Est'dentE7 rsKid ; Dal'eBo%/.Dal'e rsKname ; Te%tBo%/.Te%t rs.9pdate67 cse.con/.)ommit67 Message.0n"o6E5ecord 0nsertedE7 $N* #O5 )-OS$ B9TTON ( 9B-0) S9B B'tton2@)lick67 #Main.)lose67 $N* STEP:- -5'n the pro!ect by "ollowing steps ( /7 5OB$)T -C compile 17 *$G9G-C r'n

O9T 9T opens in new page as shown below(

:hen yo' click on view b'tton yo' will get the database in grid view as shownbelow(

STEP:. -Ao' can insert the data into database by "illing the rno and name and then clicking on 0NS$5T b'tton

STEP:/ -#inish it by clicking on )-OS$ b'tton

0ES1LT( Th's the database connectivity is established s'ccess"'lly to access the records in the database.

You might also like