2 textboxes to accept fromdate and todate and check with the database column of ida,rda and if matches then display only that row.
I tried it in the below way but not able to do.

con.Open()
        i = DataGridView1.CurrentCell.RowIndex
        cmd = New SqlCommand("SELECT COUNT(*) FROM IssueMBA WHERE ida='" + TextBox1.Text + "'and  rda='" + TextBox2.Text + "'", con)
        dr = cmd.ExecuteReader()
        If Not dr.Read() Then
            MsgBox("Invalid details")
        ElseIf ((dr(3).ToString() = TextBox1.Text) And (dr(4).ToString() = TextBox2.Text)) Then
            DataGridView1.Rows(i).Cells(0).Value.ToString()
            DataGridView1.Rows(i).Cells(1).Value.ToString()
            DataGridView1.Rows(i).Cells(2).Value.ToString()
            DataGridView1.Rows(i).Cells(3).Value.ToString()
            DataGridView1.Rows(i).Cells(4).Value.ToString()
        End If




        con.Close()

Try if the below code works fro u....

con.Open()
cmd = New SqlCommand("SELECT COUNT(*) FROM IssueMBA WHERE ida='" + TextBox1.Text + "' and rda='" + TextBox2.Text + "'", con) 'here u are giving and condition and not between check one....

dr = cmd.ExecuteReader()
If Not dr.Read() Then
MsgBox("Invalid details")
Else
 Dim dt As New DataTable
     dt.Load(myCommand.ExecuteReader)
     With DatagridView1
           .AutoGenerateColumns = True
            .DataSource = dt
     End With
End If
This article has been dead for over six months. Start a new discussion instead.