数据网格视图相关问题..... [英] data grid view related question.....

查看:88
本文介绍了数据网格视图相关问题.....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你能给我一个数据网格视图的代码吗...我想创建一个关于客户详细信息的表..我已经给出了数据..创建了表...但没有得到网格视图的代码。 ..plz帮助我

Can you please give me the code for a data grid view...i want to create a table about customer details..i had given the data..created the table..but not getting the code for grid view...plz help me

推荐答案

如果你的意思是你已经在数据库中创建了表并填充了它,那么在数据库中显示数据是一件非常重要的事情。 DataGridView:

If you mean that you have created the table in a database and populated it, it is a pretty trivial matter to display the data in a DataGridView:
using (SqlConnection con = new SqlConnection(strConnect))
    {
    con.Open();
    using (SqlDataAdapter da = new SqlDataAdapter("SELECT MyColumn1, MyColumn2 FROM myTable WHERE mySearchColumn = @SEARCH", con))
        {
        da.SelectCommand.Parameters.AddWithValue("@SEARCH", myTextBox.Text);
        DataTable dt = new DataTable();
        da.Fill(dt);
        myDataGridView.DataSource = dt;
        }
    }


这篇关于数据网格视图相关问题.....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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