How to make datagrid editable?
I searched the archives, but didn't get a clear answer. I can fill a datagrid just fine with the code below, but it doesn't save any changes back to the original table. Changes can be entered, they just don't get written back.
The examples in the books I have use a dataview, which I'd rather not use.
What am I missing? Thanks.
Code:
Private Sub FillDs()
Dim cn As New OleDbConnection()
Dim cmd As New OleDbCommand()
Dim da As New OleDbDataAdapter()
Dim strSQL, strPath, strCn, strProj As String
strSQL = "SELECT * FROM [Mod List]"
strPath = strRelPath & gstrFilePath
strCn = strProv & strPath
Try
cn.ConnectionString = strCn
cmd = cn.CreateCommand
cmd.CommandText = strSQL
da.SelectCommand = cmd
ds.Clear()
da.Fill(ds, "[Mod List]")
Catch ex As Exception
MessageBox.Show(ex.Message, "Error Reading " & strProj, MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
If cn.State = ConnectionState.Open Then
cn.Close()
End If
End Try
End Sub
Private Sub FillDataGrid()
dgMod.DataSource = ds
dgMod.DataMember = "[Mod List]"
End Sub