C#关于Atm Simulator C Sharp应用程序的帮助 [英] C# help on atm simulator c sharp application

查看:64
本文介绍了C#关于Atm Simulator C Sharp应用程序的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立了一个简单的atm模拟器..

我有一个登录系统,可移至atm模拟器菜单


其中的存款金额...

我有文本字段..

用户名:textfield
存款金额:textfield

存款按钮以存款..

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 + "''";



我只是想再次删除该用户名,然后再次删除..


我想在我们单击平衡"按钮时出现余额..无需输入用户名..帐户用户名指向当前用户,即是我指向此用户..

同样,如果我要存入金额,我也要..我只输入存入金额而没有用户名..这样,只有登录用户的金额会自动更新,而无需该支票用户名

等待答案...

解决方案

这不能回答您的实际问题,但是在SQL语句中使用参数而不是字符串文字.请参阅: http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlparameter.aspx [ ^ ].

仅举一个例子,您的数据库可能会被完全删除,或者使用写入txtusername的正确命令对机器进行了格式化. c0>代替.在循环中,请始终使用System.Text.StringBuilder.请记住,字符串是不可变的.我需要解释一下由于这个简单的事实而导致的性能损失吗?

—SA


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...

解决方案

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.


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


这篇关于C#关于Atm Simulator C Sharp应用程序的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆