Академический Документы
Профессиональный Документы
Культура Документы
Simpan tabel
(k
add
Module Module1 Public fr As New Windows.Forms.Form Public rep As Integer Public CONN As New Odbc.OdbcConnection Public CMD As New Odbc.OdbcCommand Public D !eader As Odbc.OdbcData!eader Public D table As New Data able Public "A!I#$edit As Integer % & #ub "u'a$D"() On *rror +o o C*, Dim AA As #tring AA % -Dsn%OD"C$siswa./ser ID%.PWD%.trusted$connection%0es.CONN % New Odbc.OdbcConnection(AA) CONN.Open() *1it #ub Msg"o1(*rr.Description3 Msg"o1#t4le.Information3 -CONN*C ION
C*,2
*!!O!-)
add
Buat nama (*B, n2a 3sikan nama k&mputer server tempat databasen2a
ne4t
finis1
&k
&k
Butt&n Butt&n" Butt&n5 Butt&n6 Butt&n7 *ata8rid!iew Klik kanan datagrid edit c&l&mns
str % -/PDA * table1 #* nis%?- = Me. e1t"o11. e1t = -?3nama%?- = Me. e1t"o19. e1t = -?3alamat%?- = Me. e1t"o1:. e1t = -? W8*!* nis%?- = Me. e1t"o11. e1t = -?.*nd If CMD % New Odbc.OdbcCommand(str3 CONN) CMD.*1ecuteNon@uer4() CMD.Dispose() Message"o1.#;ow(-Data suda; disimpan... -3 -"er;asil-3 Message"o1"uttons.O,3 Message"o1Icon.Information) Me.Data+rid6iew1.*nabled % rue Me."utton1.*nabled % False Me."uttonA. e1t % -"aruMe."utton:.*nabled % rue Me."utton9.*nabled % rue edit % False ,unci() !este1t() Catc; e1 As *1ception Message"o1.#;ow(- er7adi 'esala;an... - = e1.Message3 -*rror-3 Message"o1"uttons.O,3 Message"o1Icon.*rror) CMD.Dispose() *1it #ub *nd r4 *nd #ub Pri5ate #ub "utton:$Clic'("46al sender As #4stem.Ob7ect3 "46al e As #4stem.*5entArgs) 8andles "utton:.Clic' If Me. e1t"o11. e1t % -- ;en *1it #ub Dim str As #tring rep % Message"o1.#;ow(-Apa'a; data tersebut a'an di;apusB -3 -,onfirmasi-3 Message"o1"uttons.0esNo3 Message"o1Icon.@uestion) If rep % Msg"o1!esult.No ;en *1it #ub *nd If r4 str % -D*>* * F!OM table1 w;ere nis%?- = Me. e1t"o11. e1t = -?.CMD % New Odbc.OdbcCommand(str3 CONN) CMD.*1ecuteNon@uer4() CMD.Dispose() Message"o1.#;ow(-Data suda; di;apus... -3 -"er;asil-3 Message"o1"uttons.O,3 Message"o1Icon.Information) edit % False !este1t() ,unci() Catc; e1 As *1ception
Message"o1.#;ow(- er7adi 'esala;an... - = e1.Message3 -*rror-3 Message"o1"uttons.O,3 Message"o1Icon.*rror) CMD.Dispose() *1it #ub *nd r4 *nd #ub Pri5ate #ub "utton9$Clic'("46al sender As #4stem.Ob7ect3 "46al e As #4stem.*5entArgs) 8andles "utton9.Clic' If Me. e1t"o11. e1t % -- ;en *1it #ub *nd If Me."utton9.*nabled % False Me."uttonA. e1t % -"atalMe."utton:.*nabled % False Me."utton1.*nabled % rue edit % rue "u'a() Me.Data+rid6iew1.*nabled % False *nd #ub Pri5ate #ub "uttonA$Clic'("46al sender As #4stem.Ob7ect3 "46al e As #4stem.*5entArgs) 8andles "uttonA.Clic' If Me."uttonA. e1t % -"aru- ;en Me."uttonA. e1t % -"atalMe."utton1.*nabled % rue Me."utton9.*nabled % False Me."utton:.*nabled % False Me.Data+rid6iew1.*nabled % False "u'a() !este1t() Me. e1t"o11.Focus() *lse Me."uttonA. e1t % -"aruMe."utton1.*nabled % False Me."utton9.*nabled % rue Me."utton:.*nabled % rue Me.Data+rid6iew1.*nabled % rue edit % False !este1t() ,unci() *nd If *nd #ub Pri5ate #ub "uttonC$Clic'("46al sender As #4stem.Ob7ect3 "46al e As #4stem.*5entArgs) 8andles "uttonC.Clic' *nd *nd #ub Pri5ate #ub Form1$>oad("46al sender As #4stem.Ob7ect3 "46al e As #4stem.*5entArgs) 8andles M4"ase.>oad "u'a$D"()
Dari$+rid % False edit % False ,unci() Isi+rid() *nd #ub Pri5ate #ub "uttonD$Clic'("46al sender As #4stem.Ob7ect3 "46al e As #4stem.*5entArgs) *nd *nd #ub #ub "u'a() Me. e1t"o11.*nabled % Me. e1t"o19.*nabled % Me. e1t"o1:.*nabled % *nd #ub rue rue rue
#ub ,unci() Me. e1t"o11.*nabled % False Me. e1t"o19.*nabled % False Me. e1t"o1:.*nabled % False Me."utton1.*nabled % False *nd #ub #ub !este1t() Me. e1t"o11. e1t % -Me. e1t"o19. e1t % -Me. e1t"o1:. e1t % -Isi+rid() *nd #ub #ub Isi+rid() Dim El;$!ecord As #ingle Dim i As Integer Dim Data#@> As #tring % -Data#@> % - #*>*C CO/N (nis) as El; F!OM table1.CMD % New Odbc.OdbcCommand(Data#@>3 CONN) Dim D !eader$: As Odbc.OdbcData!eader D !eader$: % CMD.*1ecute!eader() If D !eader$:.!ead ;en El;$!ecord % D !eader$:(-El;-) *lse El;$!ecord % 1 *nd If D !eader$:.Close() CMD.Dispose() Data#@> % - #*>*C nis3nama3alamat F!OM able1 - = $ - O!D*! b4 nis.CMD % New Odbc.OdbcCommand(Data#@>3 CONN) D !eader$: % CMD.*1ecute!eader()
Me.Data+rid6iew1.!ows.Clear()
Me.Data+rid6iew1.!owCount % El;$!ecord Me.Data+rid6iew1.ColumnCount % D !eader$:.FieldCount F 1 i % & W;ile D !eader$:.!ead Me.Data+rid6iew1.Item(&3 Me.Data+rid6iew1.Item(13 Me.Data+rid6iew1.Item(93 Me.Data+rid6iew1.Item(:3 i % i F 1 *nd W;ile D !eader$:.Close() CMD.Dispose() *nd #ub
% % % %
i D D D
Pri5ate #ub Data+rid6iew1$Clic'("46al sender As Ob7ect3 "46al e As #4stem.*5entArgs) 8andles Data+rid6iew1.Clic' On *rror !esume Ne1t Dari$+rid % rue Me. e1t"o11. e1t % Me.Data+rid6iew1.Item(13 Me.Data+rid6iew1.Current!ow.Inde1).6alue Me. e1t"o19. e1t % Me.Data+rid6iew1.Item(93 Me.Data+rid6iew1.Current!ow.Inde1).6alue Me. e1t"o1:. e1t % Me.Data+rid6iew1.Item(:3 Me.Data+rid6iew1.Current!ow.Inde1).6alue Dari$+rid % False *nd #ub Pri5ate #ub Data+rid6iew1$,e4/p("46al sender As Ob7ect3 "46al e As #4stem.Windows.Forms.,e4*5entArgs) 8andles Data+rid6iew1.,e4/p On *rror !esume Ne1t Dari$+rid % rue Me. e1t"o11. e1t % Me.Data+rid6iew1.Item(13 Me.Data+rid6iew1.Current!ow.Inde1).6alue Me. e1t"o19. e1t % Me.Data+rid6iew1.Item(93 Me.Data+rid6iew1.Current!ow.Inde1).6alue Me. e1t"o1:. e1t % Me.Data+rid6iew1.Item(:3 Me.Data+rid6iew1.Current!ow.Inde1).6alue Dari$+rid % False *nd #ub *nd Class