0

我使用以下代码将数据添加到 DataGridView 控件中

query = "SELECT * FROM primary_student_table WHERE admityear=" & admityear & " AND batch= " & batch & ""
        da = New SqlDataAdapter(query, con)
        da.Fill(ds, "primary_student_table")
        DataGridView1.DataSource = ds.Tables("primary_student_table")

我需要稍后在同一个控件中显示另一个表中的记录,所以我需要清除表。如何在 VB.NET 中做到这一点?

我正在使用 SQL Server

4

3 回答 3

0

设置DatasourceNothing然后将其重新绑定到新表。

于 2013-07-24T15:57:39.447 回答
0

我不是专家,但我认为你想要这个。

DataGridView1.Rows.Clear()

希望它有所帮助

于 2014-10-20T12:12:08.733 回答
0

If someone still need help about clearing datagridview :

DataGridView1.Rows.Clear().

DataGridView1.Columns.Clear()

I hope it helped.

于 2016-02-03T14:37:01.253 回答