Hi
I am very new to using a datagrid and need some help if possible.
I added a Datasource in my project (Visul Studio 2005 - VB) which is connected to an Access Database.
When I make changes in the datagrid and press Save it saves and updates the info as expected.
A short while ago I added a search function with text boxes which will populate data in the same datagrid.
The problem is that when I search for a user and it displays the search result in the datagrid it won't accept any changes I make to the user's details even if I press Save. It just reverts back to the previous result which showed before doing the search.
Example:
This works: Editing a user's details in the datagrid + press save.
This does not work: Doing a search + Editing a user's details in the datagrid + press save.
Here is the code I use for doing the search:
Any help would be appreciated
I am very new to using a datagrid and need some help if possible.
I added a Datasource in my project (Visul Studio 2005 - VB) which is connected to an Access Database.
When I make changes in the datagrid and press Save it saves and updates the info as expected.
A short while ago I added a search function with text boxes which will populate data in the same datagrid.
The problem is that when I search for a user and it displays the search result in the datagrid it won't accept any changes I make to the user's details even if I press Save. It just reverts back to the previous result which showed before doing the search.
Example:
This works: Editing a user's details in the datagrid + press save.
This does not work: Doing a search + Editing a user's details in the datagrid + press save.
Here is the code I use for doing the search:
VB.NET:
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Dim strAddressSearch As String
Dim strAddressSearch2 As String
strAddressSearch = txtSearch.Text
strAddressSearch2 = txtSearch2.Text
Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=C:\mydb.mdb")
Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM Sheet1 WHERE LastName Like '%" & strAddressSearch & "%' and FirstName Like '%" & strAddressSearch2 & "%' ", con)
con.Open()
Dim myDA As OleDbDataAdapter = New OleDbDataAdapter(cmd)
Dim myDataSet As DataSet = New DataSet()
myDA.Fill(myDataSet, "MyTable")
Sheet1DataGridView.DataSource = myDataSet.Tables("MyTable").DefaultView
End Sub
Any help would be appreciated