如何编写查询以使用gridview在asp.net中检索数据库值thorugh编码 [英] how to write the query for retriving the databse value thorugh coding in asp.net using gridview

查看:41
本文介绍了如何编写查询以使用gridview在asp.net中检索数据库值thorugh编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有设计应用程序

UserID TextBox1

SubmitButton


数据库如下;

用户ID名称地址
1个金奈
2 B德里
3 C孟买

在运行模式下,在textbox1中,当我键入partiuclar userid并单击提交"按钮时,将在网格视图中显示特定数据.请发送代码.帮助我.

i have design application

UserID TextBox1

SubmitButton


database as follows;

UserID Name Address
1 A Chennai
2 B Delhi
3 C Mumbai

in run mode in textbox1 when i type partiuclar userid and click the submit button the particular data to be displayed in the grid view.please send the code.help me.

推荐答案

这里我正在使用SQL数据库..因此,请按照此进行连接..

here I''m using SQL Database.. so make the connection as per this..

string query="select * from table_name where UserID='"+userID+"'";
SqlDataAdapter da=new SqlDataAdapter(query, here your connection object or connection string);
DataTable dt=new DataTable();
da.Fill(dt);

DataGridView1.DataSource=dt;
DataGridView1.DataBind();     // optional


这篇关于如何编写查询以使用gridview在asp.net中检索数据库值thorugh编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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