Private Sub btnload_Click(sender As Object, e As EventArgs) Handles btnload.Click
        Dim sqlquery As String = "select frmStudentReg.regno,nursery.rollno,[nursery.nepali(writing)],[nursery.nepali(oral)],[nursery.maths(writing1)],[nursery.maths(oral)],[nursery.maths(writing2)],[nursery.english(writing)],[nursery.english(oral)],[nursery.physical_edu(oral)],[nursery.creative(oral)] from frmStudentReg,nursery where frmStudentReg.regno=nursery.regno"
        Dim sqlcommand As New OleDbCommand
        Dim sqladapter As New OleDbDataAdapter
        Dim table As New DataTable
        With sqlcommand
            .CommandText = sqlquery
            .Connection = conn
            .ExecuteNonQuery()

        End With
        With sqladapter
            .SelectCommand = sqlcommand
            .Fill(table)
        End With
        DataGridView1.Rows.Clear()

        For i = 0 To table.Rows.Count - 1
            With DataGridView1
                .Rows.Add(table.Rows(i)("frmStudentReg.regno"), table.Rows(i)("nursery.rollno"), table.Rows(i)("nursery.nepali(writing)"), table.Rows(i)("nursery.nepali(oral)"), table.Rows(i)("nursery.maths(writing1)"), table.Rows(i)("nursery.maths(oral)"), table.Rows(i)("nursery.maths(writing2)"), table.Rows(i)("nursery.english(writing)"), table.Rows(i)("nursery.english(oral)"), table.Rows(i)("nursery.physical_edu(oral)"), table.Rows(i)("nursery.creative(oral)"))
            End With
        Next
    End Sub

hi this is my code for loading multiple table data to one datagridview. but i found the type mismatch expression error.. i think its error in my query. plz help asap..

My guess would be this statement:

.Rows.Add(table.Rows(i)("frmStudentReg.regno"), table.Rows(i)("nursery.rollno"), table.Rows(i)("nursery.nepali(writing)"), table.Rows(i)("nursery.nepali(oral)"), table.Rows(i)("nursery.maths(writing1)"), table.Rows(i)("nursery.maths(oral)"), table.Rows(i)("nursery.maths(writing2)"), table.Rows(i)("nursery.english(writing)"), table.Rows(i)("nursery.english(oral)"), table.Rows(i)("nursery.physical_edu(oral)"), table.Rows(i)("nursery.creative(oral)"))

You need to set column values and I don't think the Rows.Add method allows that.

Something like this would work:

With DataGridView1
    Dim dgvr As New DataGridViewRow
        'add cells/values
    DataGridView1.Rows.Add(dgvr)
End With
This article has been dead for over six months. Start a new discussion instead.