Hi
I have a 2form.
1-I have a form interface that is the basic interface with DataGrid View to display data.
2-I have another interface for adding and modifying operations like Inside the input tools are Text, Label and DataTime ....
The operations are done in an excellent way, but the problem is that I want to update the datagrid on the first interface with new data after updating or modifying or insert add, but the process is not completed when it is placed with the add or modification code and is called the Add and Modify interface.
Note that if you perform the operation with a different button or sub, it will take place without problems, I mean to update the data
Sub UpdateEmployee()
Try
Dim com As New OleDbCommand("UPDATE EMPLOYEE_TB SET EMPLOYEE_NAME =@EMPLOYEE_NAME, EMPLOYEE_NATURALWORK =@EMPLOYEE_NATURALWORK, EMPLOYEE_ADDRESS =@EMPLOYEE_ADDRESS, EMPLOYEE_TELEPHON =@EMPLOYEE_TELEPHON, EMPLOYEE_SALARY =@EMPLOYEE_SALARY, EMPLOYEE_NOTE =@EMPLOYEE_NOTE, EMPLOYEE_DATE =@EMPLOYEE_DATE WHERE EMPLOYEE_CODE =@EMPLOYEE_CODE", con)
com.Parameters.AddWithValue("@EMPLOYEE_NAME", OleDbType.VarChar).Value = EMPLOYEEUPDATE.TEXT_EMPLOYEE.Text
com.Parameters.AddWithValue("@EMPLOYEE_NATURALWORK", OleDbType.VarChar).Value = EMPLOYEEUPDATE.COMBO_NATURAL.SelectedItem
com.Parameters.AddWithValue("@EMPLOYEE_ADDRESS", OleDbType.VarChar).Value = EMPLOYEEUPDATE.TEXT_CLIENTADDRES.Text
com.Parameters.AddWithValue("@EMPLOYEE_TELEPHON", OleDbType.VarChar).Value = EMPLOYEEUPDATE.TEXT_CLIENTTELEPHON.Text
com.Parameters.AddWithValue("@EMPLOYEE_SALARY", OleDbType.Single).Value = EMPLOYEEUPDATE.TEXT_SALARY.Text
com.Parameters.AddWithValue("@EMPLOYEE_NOTE", OleDbType.VarChar).Value = EMPLOYEEUPDATE.TEXT_CLIENTNOT.Text
com.Parameters.AddWithValue("@EMPLOYEE_DATE", OleDbType.Date).Value = EMPLOYEEUPDATE.DATATIM_DATERECOR.Value.ToShortDateString
com.Parameters.AddWithValue("@EMPLOYEE_CODE", OleDbType.VarChar).Value = EMPLOYEEUPDATE.LAB_CODEVAL.Text
con.Open()
com.ExecuteNonQuery()
con.Close()
'The following code. The update code with the new data does not show or is ignored.؟؟؟؟
Dim DataAdapter As New OleDbDataAdapter("SELECT TOP 1 EMPLOYEE_ID,EMPLOYEE_CODE,EMPLOYEE_NAME,EMPLOYEE_NATURALWORK,EMPLOYEE_TELEPHON FROM EMPLOYEE_TB WHERE EMPLOYEE_CHECK=TRUE AND EMPLOYEE_ID = " & EMPLOYEEUPDATE.LAB_IDVAL.Text.Trim & " ORDER BY EMPLOYEE_NAME ASC", con)
DTATGREG.Clear()
DataAdapter.Fill(DTATGREG)
Catch ex As Exception
Exit Sub
End Try
End Sub