如何在cellcontentclick上获取数据frm数据库 [英] how to fetch data frm database on cellcontentclick

查看:71
本文介绍了如何在cellcontentclick上获取数据frm数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Visual Studio 2008和数据库SQL 2005中开发Windows应用程序.在该项目中,我正在使用Datagridview,并从该datagridview中使用事件CellContentClick ...我想在单击datagridview单元格时从数据库中获取数据. ...如何为此编写代码....请任何人帮我解决这个问题....

i am developing windows application in visual studio 2008 and database SQL 2005. In that project i am using Datagridview and from that datagridview i use event CellContentClick...i want to fetch data from database on click of the cell of datagridview....how to write the code for it ....please any one help me out to solve this problem....

推荐答案

向事件添加处理程序:
(这样的事情)
Add handler to the event:
(Something like this)
protected void CellContent_Click(ObjectSender sender, EventArgs eventArgs)
{
// data access code here.
}



要访问数据,您需要创建连接对象,将其打开,创建命令,执行并处理结果.
可以在此处找到一些示例:
数据读取器示例 [



To access data you will need to creayte connection object, open it, create command, execute it and process the results.
Some examples can be found here:
Data reader example[^]


这篇关于如何在cellcontentclick上获取数据frm数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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