Private Sub btnupdate_Click(sender As Object, e As EventArgs) Handles btnupdate.Click
        Dim myindex As Integer
        Dim reg As Integer
        Dim roll As Integer
        Dim nepaliw As Integer
        Dim nepalio As Integer
        Dim mathw1 As Integer
        Dim matho As Integer
        Dim mathw2 As Integer
        Dim engw As Integer
        Dim engo As Integer
        Dim pe As Integer
        Dim creative As Integer

        myindex = DataGridView1.CurrentRow.Index
        reg = DataGridView1.Item(0, myindex).Value
        roll = DataGridView1.Item(1, myindex).Value
        nepaliw = DataGridView1.Item(2, myindex).Value
        nepalio = DataGridView1.Item(3, myindex).Value
        mathw1 = DataGridView1.Item(4, myindex).Value
        matho = DataGridView1.Item(5, myindex).Value
        mathw2 = DataGridView1.Item(6, myindex).Value
        engw = DataGridView1.Item(7, myindex).Value
        engo = DataGridView1.Item(8, myindex).Value
        pe = DataGridView1.Item(9, myindex).Value
        creative = DataGridView1.Item(10, myindex).Value

        Dim sqlquery As String = "update nursery set rollno='" & roll & "',[nepali(writing)]='" & nepaliw & "',[nepali(oral)]='" & nepalio & "',[maths(writing1)]='" & mathw1 & "',[maths(oral)]='" & matho & "',[maths(writing2)]='" & mathw2 & "',[english(writing)]='" & engw & "',[english(oral)]='" & engo & "',[physical_edu(oral)]='" & pe & "',[creative(oral)]='" & creative & "' where regno='" & reg & "'"
        Dim sqlcommand As New OleDbCommand
        With sqlcommand
            .CommandText = sqlquery
            .Connection = conn
            .ExecuteNonQuery()

        End With
    End Sub

plz help me i get this error while updating.. regno is autonumber n all fields are integer

for integer datatype , you have to conver your values into integer first , like this

Dim myindex As Integer
myindex = val(DataGridView1.CurrentRow.Index)

Regards

thanx waqas aslam

if problem is solved , please mark this thread solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.