Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL Query Is Not Working

Author  Topic 

AhmetEmre90
Starting Member

5 Posts

Posted - 2011-07-01 : 08:23:25
i'm making a web service, program is working fine except one query.
the red code piece is working after "else" statement worked but it is not working after "if" or "else if" is worked. how can i fix this problem


Connection conn = DriverManager.getConnection(url, username, password);
Statement stat = conn.createStatement();
Statement stat2 = conn.createStatement();
Statement stat3 = conn.createStatement();

ResultSet rs = stat.executeQuery("SELECT borcmiktari FROM fatura_bilgileri WHERE faturaid=" + faturaidd);
while (rs.next()) {
borc = rs.getDouble("borcmiktari");
}

if (borc == odenenmiktarr) {
stat2.executeQuery("UPDATE fatura_bilgileri SET odenenmiktar=" + odenenmiktarr + ", durum ='Odenmis' WHERE faturaid=" + faturaidd);
} else if (borc > odenenmiktarr) {
stat2.executeQuery("UPDATE fatura_bilgileri SET odenenmiktar=" + odenenmiktarr + ", durum ='Borclu' WHERE faturaid=" + faturaidd);
} else {
str = "Hata Olustu";
}

ResultSet rs2 = stat3.executeQuery("SELECT durum FROM fatura_bilgileri WHERE faturaid=" + faturaidd);
while (rs2.next()) {
strDrm = rs2.getString("durum");
}



http://ahmetemremermer.com

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-07-08 : 04:56:27
You should post this in a .NET forum

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2011-07-08 : 06:26:52
Also read up on SQL Injection. Your code has a security vulnerability in it.

--
Gail Shaw
SQL Server MVP
Go to Top of Page
   

- Advertisement -