Reputation: 235
I am creating a GUI bank project in netbeans that uses mysql database. I set the account numbers as primary key and I want the user to deposit money only if they put in their correct account number. When I tried to do this, only one row works, how do I make so that whenever the account number is entered and the amount for the deposit is entered, it will update the balance column. Here is my query statement:
String Query = "UPDATE ACCOUNTINFO SET BALANCE = '"+txtAmount.getText()+"'
WHERE ACCOUNTNUMBER = '"+txtAccountNum.getText()+"'";
Upvotes: 1
Views: 1880
Reputation: 4562
String Query = "UPDATE ACCOUNTINFO SET
BALANCE = '"+txtAmount.getText()+"',
WITHDRAWL_LIMIT = '"+txtLimit.getText()+"'
WHERE ACCOUNTNUMBER = '"+txtAccountNum.getText()+"'";
Upvotes: 0
Reputation: 732
Updating multiple columns works like this:
UPDATE table SET colum1 = value1, column2 = value2 WHERE key_column = compare_value;
Upvotes: 1
Reputation: 816
Remove + " which you have written before WHERE clause in your query. and its UPDATE not UPDATA Please correct it.
Upvotes: 0
Reputation: 439
You can make menu driven program. Firstly you print all the functions that is available like show balance, withdraw money,Deposite money,etc .Give numbers to choices and then take input number and then use switch case and match the choice and ask inputs accordingly like you want only acc number or acc number and amount. And after operation is complete you can ask user if he want continue ? Check if he types yes or no in do..while loops condition if he pressed yes then show menu again.
Upvotes: 0