Click here to Skip to main content
15,918,516 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
i bulid a simple atm simulator..

i have a login system to move to the atm simulator menu


in which for depositing amount...

i have text fields..

user name: textfield
deposit amount: textfield

deposit button to deposit money..

MAcmd.CommandText = "Update registeraccount Set Balance =Balance+'" + c + "'where username='" + txtusername.Text + "'"; same for the balance inquiry menu..

MAcmd.CommandText = "SELECT * FROM registeraccount WHERE username='" + textBox1.Text + "'";


I jusst want to erase that username check again nd again..


i want tha balance just appears as we click balace button.. no need to enter the username.. acount username is pointing the current user thats y i point this..

simlarly i want that if i deposit amount.. i just enter the deposit amount and no user name.. so that just the amount of login user update automatically without that check username

waiting for answer...
Posted
Updated 23-Mar-11 8:10am
v3

This doesn't answer your actual question but use parameters instead of string literals in you SQL statements. See: http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlparameter.aspx[^].

Just an example, your database could be totally erased or the machine formatted with proper commands written to the txtusername.
 
Share this answer
 
Just a side note: never use multiple "+" to concatenate strings, use string.Format instead. In the loop, always use System.Text.StringBuilder. Remember, strings are immutable. Do I need to explain how much would be the performance leak due to this simple fact?

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900