I have limited knowledge in coding.
can anyone tell me what is worng with my code?
the firstrow result in the database is not updated, but it is updated in datagridview.

For i As Integer = 0 To DataGridView1.RowCount - 1
            DataGridView1.Rows(i).Cells(11).Value = "true"
        Next
        SmsdDataSet.AcceptChanges()

Recommended Answers

All 2 Replies

You have to update the datasource of the datagrid view.

A DataAdapter will do the job:

Dim da As OleDB.OleDBDataAdapter(New OleDB.OleDBCommand("SELECT * FROM TabelName",MyDbConnection)) 'Make sure the connection passed in is open.
da.UpdateCommand = New OleDBCommandBuilder(da).GetUpdateCommand()' If not you will have to open the connection before calling this line.
da.Update(MyDataGridViewSource) 'Where MyDataGridViewSource is a DataSet

thank you but the result is still leaving out the first row.
but stressed from unable to do it, so I have no choice I just update it straight to the database using

mysqlcommand.commandtext
mysqlcommand.ExecuteNonQuery()
mytransaction.Commit()
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.