且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在VB.NET中的datagridview中显示特定单元格的数量

更新时间:2023-12-03 12:14:16

有两种可能的方法来实现:

There's 2 possible ways to achieve that:


  1. 通过过滤数据库

    您需要创建OleDbCommand [ ^ ]:


  1. via filter database
    You need to create OleDbCommand[^] with query:
SELECT <<list_of_columns>>
FROM Studentsgrade
WHERE [Student Name] LIKE @name OR [ID No] LIKE @id OR [Group] LIKE @grp OR [C1] LIKE @c1 OR [C2] LIKE @c2



并将您在 where 子句中定义的参数数量传递给 OleDbCommand.Parameters [ ^ ]集合。

能够将数据加载到DataTable [ ^ ]你必须使用 OleDbReader [ ^ ]通过 OleDbCommand.ExecuteReader()方法 [ ^ ]。br $>

  • 通过过滤器数据集

    对于MS Access数据库,一些程序员更喜欢使用其方法过滤数据表 [ ^ ]有些人喜欢使用 Linq to dataset [ ^ ]。


  • and pass the number of arguments you define in where clause to OleDbCommand.Parameters[^] collection.
    To be able to load data to DataTable[^] you have to use OleDbReader[^] through the OleDbCommand.ExecuteReader() method[^].

  • via filter dataset
    For MS Access database some programmers prefer to filter datatable by using its method[^] and some prefer to use Linq to dataset[^].






  • 详情请参阅:

    OleDbParameterCollection.AddWithValue Method(String,Object)(System.Data.OleDb) [ ^ ]

    Visual Basic中的LINQ简介 [ ^ ]

    LINQ to DataSet示例 [ ^ ]

    从查询(LINQ到DataSet)创建DataTable [ ^ ]

    LINQ to DataSet中的查询 [ ^ ]




    For further details, please read:
    OleDbParameterCollection.AddWithValue Method (String, Object) (System.Data.OleDb)[^]
    Introduction to LINQ in Visual Basic[^]
    LINQ to DataSet Examples[^]
    Creating a DataTable From a Query (LINQ to DataSet)[^]
    Queries in LINQ to DataSet[^]