Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
nk compare statement nie
30-05-2012, 12:57 PM,
Post: #1
nk compare statement nie
salam....

saya nk mintak bantuan rakan2..

saya nk compare statement nie utk kalau dyer ader input dari database, bru dyer execute statement button1.setBackground(color.red) ....kalu dyer xder input x nk kasi dyer execute code bawah2 ....

skrg nie dyer sentiasa executed jer...

mintak tlg..

Quote:if ((stmt.execute("select `rule_id` from `alert` where location_id= "+pc1) ) && (stmt.execute("select `rule_id` from `alert` where timestamp="+1337193472)))

{
button1.setBackground(Color.red);

}
Reply
30-05-2012, 01:03 PM,
Post: #2
RE: nk compare statement nie
kalau ade if, kena ada else.. dlm else tu masukkan something error..
susah nk explain.. xpndai sgt..hehe
[Image: pumpkids]
Reply
30-05-2012, 01:14 PM, (This post was last modified: 30-05-2012, 01:14 PM by ZackStark.)
Post: #3
RE: nk compare statement nie
yang aku nampak bila kau panggil dari database, kau tak assign dia dgn mana2 value, so cam takleh compare,

cadangan aku, get data from database, assign to a value, then compare, nampak teratur sket kot...
tu yg biasa aku buat punFuck That Shit
Kalo saya buat salah janganlah marah mcm GayFace
Reply
30-05-2012, 01:24 PM, (This post was last modified: 30-05-2012, 01:24 PM by crashman_xx.)
Post: #4
RE: nk compare statement nie
Quote: query = "select `rule_id` from `alert` where location_id= "+pc1;

rs = stmt.executeQuery(query);


if (rs != null)

{

rs = stmt.getResultSet();
button1.setBackground(Color.red);

}

ok da ubah jadi cam nie...tpi x dpt execute plak setbackground 2...ader cdgn?

Reply
30-05-2012, 06:43 PM, (This post was last modified: 30-05-2012, 06:44 PM by sno0p.)
Post: #5
RE: nk compare statement nie
aku rasa ko tak set button1 tuh...
cuba guna JButton component...

Java class java.awt.Color tu jangan lupa masukkan nanti...

Then cuba kod

JButton btn = new JButton("Nama Butang");
button1.setBackground(Color.RED);

Harap dapat membantu.
Sleepy
Reply
30-05-2012, 10:12 PM, (This post was last modified: 30-05-2012, 10:19 PM by cupin06.)
Post: #6
RE: nk compare statement nie
(30-05-2012, 06:43 PM)sno0p Wrote: aku rasa ko tak set button1 tuh...
cuba guna JButton component...

Java class java.awt.Color tu jangan lupa masukkan nanti...

Then cuba kod

JButton btn = new JButton("Nama Butang");
button1.setBackground(Color.RED);

Harap dapat membantu.
Maksudnya coding x de error tapi cuma background button tu je la x tukar.klu x tukar cuba letak validate() and repaint()

Code:
button1.setBackground(Color.RED);
    repaint();
    validate();

contoh sebelum tu ko dh set button1 tu background dia color grey.
lepas dia execute if statement tu kalau ada value dia akan tukar background button1 jadi red.
so..kalau ko nk ubah ape2..mostly ko kena validate().validate ni untuk dia refresh kembali JFrame

x pn klu x leh..cuba ko paste coding gui ko.

[Image: Untitled-1.png]
Reply
31-05-2012, 12:28 AM,
Post: #7
RE: nk compare statement nie
tq bro for rep....saya da dpt taw nper mslh...tpi xtaw aper dyer solution dyer ag...maser saya query database, return value yg sepatutnya null dyer x detect sebgai null...dyer detect sebagai value jugak...walaupun nilai dyer xder aper2 still baca sebagai null juga...


cth:
Quote:query = "select `rule_id` from `alert` where location_id=1000";

rs = stmt.executeQuery("select `server_id` from `agent`");

dalam crite nie...location id xder smpi 100.,so dyer akan retrun null ptnyer...tpi dyer x return null n x return error...just return xder mende n but x return null...
Reply
31-05-2012, 12:36 AM, (This post was last modified: 31-05-2012, 12:44 AM by cupin06.)
Post: #8
RE: nk compare statement nie
(31-05-2012, 12:28 AM)crashman_xx Wrote: tq bro for rep....saya da dpt taw nper mslh...tpi xtaw aper dyer solution dyer ag...maser saya query database, return value yg sepatutnya null dyer x detect sebgai null...dyer detect sebagai value jugak...walaupun nilai dyer xder aper2 still baca sebagai null juga...


cth:
Quote:query = "select `rule_id` from `alert` where location_id=1000";

rs = stmt.executeQuery("select `server_id` from `agent`");

dalam crite nie...location id xder smpi 100.,so dyer akan retrun null ptnyer...tpi dyer x return null n x return error...just return xder mende n but x return null...

susah nk ckpla bro sbb x leh nk tgk ko punya coding..kalo ko leh share kt sini ko nya coding yang nk connect database tu leh aku try godek2 tgk.

Maksud ko bila ko query from database kalau location id lebih dari sepatutnya dia akan return null and return error.contoh database ko ada location smpai 100, bila ko query lebih dari 100 dia akan return null and error ke???
[Image: Untitled-1.png]
Reply
31-05-2012, 02:39 AM,
Post: #9
RE: nk compare statement nie
salam..saya dah dpt solution nyer..sy gune multipleif dalam satu rs...yg maner x boley jadik...tq pada semua yg sudi bantu...

Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Selection Statement sno0p 0 534 19-02-2009, 02:16 PM
Last Post: sno0p

Forum Jump: