在文本框中更新数据 [英] updata data in the textbox

查看:68
本文介绍了在文本框中更新数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我该如何使用保存"按钮在文本框中及其上的数据更新数据,以再次将这些更改保存在sql数据库中.

我已经尝试过这个了:
如何在where条件中指定行索引?

How can i updata data in the textbox and them with a"save" button.. to save this changes again in the sql database.

I have tried this one:
How can i specify in the where condition, the row index??

OleDbCommand myComm = new OleDbCommand("UPDATE Customer SET Code='" + txt_code.Value + "', Description='"+txt_desc.Value+ "', DescLong = '" + txt_longdesc.Value+ "', Tel='"+txt_tel.Value+ "', Mobile = '" + txt_mobile.Value+ "' ,  WHERE ????=" + ????+ , con );

推荐答案

在单击保存"按钮时,请按照以下代码编写dowo

on the click of save button write dowo following code

 cmd=new SQlcommand("update tablename set columnname='"+textbox.text +"' where id='"+id+"'",con);
con.open();
cmd.executeNonQUery();
con.close();



其中con是连接对象
sqlcommand对象中的cmd
id是要为其更新行的主键



where con is connection object
cmd in sqlcommand object
id is the primary key for which row you want to update


假设您想知道如何将数据保存在DB中,这可能对您有用:
Assuming you want to know how to save the data in DB, This could be useful for you: A Beginner''s Tutorial for Understanding ADO.NET[^]


这篇关于在文本框中更新数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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