Visual basic

Muana Ralte 21 Reputation points
2021-10-07T20:53:22.463+00:00

138691-img-20211008-021454.jpg

What do i do if i only want to display Class I
I'm using visual basic 2017, access database, window form.vb
And thank you for your time

Microsoft 365 and Office Access Development
Developer technologies VB
0 comments No comments
{count} votes

Accepted answer
  1. Xingyu Zhao-MSFT 5,381 Reputation points
    2021-10-08T03:39:19.887+00:00

    Hi @Muana Ralte ,
    It seems that you have retrieved a table from Access and display it on DataGridView.

    What do i do if i only want to display Class I

    Basically, you can refer to the following code.

            Using cnn As OleDbConnection = New OleDbConnection(connstring)  
                Dim cmd As New OleDb.OleDbCommand()  
                cmd.Connection = cnn  
                cmd.CommandText = "SELECT * FROM yourTable WHERE Class = @class"  
                cmd.Parameters.AddWithValue("@class", "Class I")  
                cnn.Open()  
                Dim da As New OleDb.OleDbDataAdapter(cmd)  
                Dim dt As New DataTable  
                da.Fill(dt)  
                Me.DataGridView1.DataSource = dt  
            End Using  
    

    Besides, if I have any misunderstanding, please provide more details or related code here. It will help us make a test.

    Best Regards,
    Xingyu Zhao
    *
    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.