i wrote code , getting 2 errors:
'else' must preceded matching 'if' or 'elseif'.
expression expected.
here code:
imports system.data.odbc public class formlogin dim cmd new odbccommand dim rd odbcdatareader private sub button1_click(byval sender system.object, byval e system.eventargs) handles button1.click if textbox1.text = "" or textbox2.text = "" msgbox("data login belum lengkap!") exit sub else call koneksi() cmd = new odbccommand("select * tbl_admin kode_admin=" & textbox1.text & "and password_admin=" & textbox2.text &, conn) rd = cmd.executereader rd.read() if rd.hasrows me.close() formmenuutama.show() formmenuutama.logintoolstripmenuitem.enabled = false formmenuutama.logouttoolstripmenuitem.enabled = true formmenuutama.mastertoolstripmenuitem.enabled = true formmenuutama.transaksitoolstripmenuitem.enabled = true formmenuutama.laporantoolstripmenuitem.enabled = true else msgbox("kode admin atau password salah") end if end sub private sub formlogin_load(byval sender system.object, byval e system.eventargs) handles mybase.load textbox1.maxlength = 6 textbox2.passwordchar = "*" textbox1.clear() textbox2.clear() end sub private sub button2_click(byval sender system.object, byval e system.eventargs) handles button2.click me.close() end sub end class
1) not put code after then
in if
statement . becomes 1 line
so:
if textbox1.text = "" or textbox2.text = "" msgbox("data login belum lengkap!") ...
instead of
if textbox1.text = "" or textbox2.text = "" msgbox("data login belum lengkap!") ...
2) there &
so:
cmd = new odbccommand("select * tbl_admin kode_admin=" & textbox1.text & "and password_admin=" & textbox2.text , conn)
instead of
cmd = new odbccommand("select * tbl_admin kode_admin=" & textbox1.text & "and password_admin=" & textbox2.text &, conn)
Comments
Post a Comment