Private Sub DataGridView1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.SelectionChanged
Dim con As New SqlClient.SqlConnection("data source=GOLDA2\GOLDA;initial catalog=school;Integrated Security=True")
Dim sql As String = "Select * from fees where particulars=" & "'DataGridView1.Rows(0).Cells(1).Value'" & ""
Dim dataadapter As New SqlDataAdapter(sql, con)
Dim ds As New DataSet()
con.Open()
dataadapter.Fill(ds, "fees")
con.Close()
For j As Integer = 0 To DataGridView1.RowCount - 1
If DataGridView1.Rows(j).Cells(1).Value = "Lab" Then
DataGridView1.Rows(j).Cells(2).Value = ds.Tables("fees").Rows(j).Item(2)
End If
Next
End Sub
when i run the above code in VB.net it shows that "There is no row at position 0."
Recommended Answers
Jump to PostAfter running this code did you check there is table in dataset? And table has rows?
All 3 Replies
Pgmer
50
Master Poster
Featured Poster
santhini
0
Newbie Poster
hericles
289
Master Poster
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.