如何增加表中存储的值以及如何在文本框中显示? [英] How can increase the value stored in table and how can show in text box?

查看:65
本文介绍了如何增加表中存储的值以及如何在文本框中显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用vs2008在Windows应用程序中创建表单.我使用了一个文本框和一个按钮.当我按下按钮时,文本框将不得不显示存储在表中的最后一个值.例如,Employee表具有名为ID的列.在该column(ID)中有6个ID.现在,当我按下按钮时,该文本框应显示为6.

谢谢与问候

Viswanathan.M

Hi,

I am creating a form in windows application using vs2008. I have use one text box and one button. when i press the button, the text box will have to show the last value stored in table.For example,Employee table has the column named as ID.In that column(ID) has 6 ids. Now when i press the button,that text box should show 6.

Thanks & Regards

Viswanathan.M

推荐答案

为实现此通用目的,您需要将test转换为int并再次返回:幸运的是,这很容易,因为.NET提供了int.Parse [ ToString []方法.

由于这是您的家庭作业,因此您可以编写代码!

1)将TextBox的初始值设置为"1"
2)在Button.Click事件处理程序中,读取TextBox Text属性的值,并检查它是否包含一些数据.如果是这样,请使用Parse方法将其转换为整数.
3)将值保存到数据库-您可能需要SqlConnection和SQLCommand对象.您的讲义应涵盖这一部分.
4)如果保存成功,则将其添加到整数,然后使用ToString方法将TextBox.Text属性设置为新值.
5)如果没有向用户解释原因!
To make this general purpose, you need to convert test to int and back again: fortunately this is easy as .NET provides the int.Parse[^] and ToString[^] methods respectively.

Since this is your homework, you can write the code!

1) Set the initial value of your TextBox to "1"
2) In your Button.Click event handler, read the value of your TextBox Text property and check it has some data. If it does, use the Parse methods to convert it to an integer.
3) Save the value to your database - you will probably need a SqlConnection and a SQLCommand objects. Your lecture notes should cover this part.
4) If it saved ok, add one to the integer, and set the TextBox.Text property to the new value using the ToString method.
5) If it didn''t explain why to the user!


这篇关于如何增加表中存储的值以及如何在文本框中显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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