如何在Windows应用程序的datagridview中检索值. [英] How to retrieve values in datagridview in windows applications.

查看:62
本文介绍了如何在Windows应用程序的datagridview中检索值.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我想使用c#语言在带查询的datagridview中显示一些表详细信息.请提供一些代码的帮助..

Hi to All,


i want to display some table details in datagridview with query by using c# language.please help with some code..

推荐答案

static string ConStr = @"Data Source=ROHIT-PC\SQLEXPRESS;Initial Catalog=MPAdvisor;Integrated Security=True";
        SqlConnection con = new SqlConnection(ConStr);

string query = "select * from users";

            SqlDataAdapter da = new SqlDataAdapter(query, con);
            DataTable dt = new DataTable();
            da.Fill(dt);
           
            GridView1.DataSource = dt;


请参阅这些链接以获取示例代码
C#DataGridView绑定-SQL Server数据集 [如何:将数据绑定到Windows窗体DataGridView控件 [
Refer these links for sample code
C# DataGridView Binding - SQL Server dataset[^]
How to: Bind Data to the Windows Forms DataGridView Control[^]


这篇关于如何在Windows应用程序的datagridview中检索值.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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