Hi. I have a form with some textboxes to save data to a 2003 access db. The saving to db works 100 %. I then have the option to go to form 2, where I can search, from a textbox, data in a datagridview (which is bind to access db). The problem is that if I add a new line to the db, and want to search for it from the textbox in form2, then it does not show when searched for. It does however show, in the datagridview, when the form is loaded. Only when the app is published, again, then the last line will show when filtered. I have tried all the options for Dataviewrowstatus, but results is the same.
Code for saving to db:
Dim conString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Sir Hickman\Documents\Visual Studio 2019\Staff\Staff\Staff\ActionsData.mdb;"
Dim con As OleDbConnection = New OleDbConnection(conString)
Dim cmd As OleDbCommand
Dim dt As DataTable = New DataTable()
Dim SQL As String = "INSERT INTO ActionsData(Staff_number,Employee_name,Warning_date,Warning_Action,Validity,Expiration,Upload) Values(Staff_number,Employee_name,Warning_date,Warning_Action,Validity,Expiration,Upload) "
cmd = New OleDbCommand(SQL, con)
cmd.Parameters.AddWithValue("Staff_number", TextBox1.Text)
cmd.Parameters.AddWithValue("Employee_name", TextBox2.Text)
cmd.Parameters.AddWithValue("Warning_date", DateTimePicker1.Text)
cmd.Parameters.AddWithValue("Warning_Action", ComboBox1.Text)
cmd.Parameters.AddWithValue("Validity", ComboBox2.Text)
cmd.Parameters.AddWithValue("Experiration", DateTimePicker2.Text)
cmd.Parameters.AddWithValue("Upload", "Yes")
Try
con.Open()
If cmd.ExecuteNonQuery() > 0 Then
Label9.Text = "Info Successfully Updated"
End If
con.Close()
Catch ex As Exception
MsgBox(ex.Message)
con.Close()
End Try
Code on textbox to filter datagridview:
dv = New DataView(ActionsDataDataSet4.Tables(0), "Employee_name= '" & TextBox1.Text & "' ", "Employee_name", DataViewRowState.CurrentRows)
DataGridView2.DataSource = dv
What I have tried:
Search and Filtering of datagridview, from textbox, does not include the last new entry to database.