this is my code.

Private Sub cmdSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSearch.Click
        temp = "DaftarGaji"
        modPY.LookUp("SELECT * FROM MS_UMR ORDER BY TAHUN", strCONNECT, 0, 1, temp)    End Sub
Public Sub LookUp(ByVal strRecordtoSearch As String, ByVal strCONNECT As String, ByVal KeyFieldPos As Short, ByVal ResultFieldPos As Short, Optional ByVal temp As String = "")

        frmLookup1.RecordSource(strRecordtoSearch) '.RecordSource = strRecordtoSearch
        frmLookup1.strConnection(strCONNECT)
        frmLookup1.KeyField(KeyFieldPos)
        frmLookup1.FieldtoReturn(ResultFieldPos)

        frmLookup1.Text = "Result Collection ..."
        frmLookup1.ShowDialog()

    End Sub
Public Sub RecordSource(ByVal value As String)

        strSQL = value

 End Sub
Private Sub Frmlookup1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        If strSQL <> Nothing Then

         
            grdDISPLAY.Columns.Clear()


             If rs.State = ADODB.ObjectStateEnum.adStateOpen Then rs.Close()

            rs.Open(strSQL, adcLEDGER, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockPessimistic)

            custDA.Fill(datatable, rs)

           

            grdDISPLAY.DataSource = datatable
            grdDISPLAY.Refresh()




        End If


    End Sub

How can i clear my datagridview. Pleas help me. Thank's

when i want see my result. for example: "SELECT * FROM MS_UMR ORDER BY TAHUN" i want query this to my result and it occur some duplicate result in my datagridview, than i need to clear it first and then just run the query to avoid my result occur previous result

Delete a record from the database using methods of Command class.

Dim Cmd as new SqlCommand
....
Cmd.ExecuteNoneQuery
...
This article has been dead for over six months. Start a new discussion instead.