Как мне...обновить свою базу данных access
как я могу обновить свою базу данных access в vb.net код я использую OleDb соединение с базой данных это сделать изменение в datagridview но не в базу данных
Public Sub executquery() Dim commandOleDb As New OleDbCommand(query, con) commandOleDb.ExecuteNonQuery() con.Close() End Sub -------------------- Private Sub ButtonInsert_Click(sender As Object, e As EventArgs) Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Almaashat.accdb") Dim query As String Try con.Open() query = "INSERT INTO Techers (File_ID,Name,Workplace,Jop,Appointment,Class,Birthday,End_date,End_class,End_for,Note) VALUES (" & TextBoxFile_ID.Text & " ,'" & TextBoxName.Text & "' ,'" & TextBoxWorkplace.Text & "' ,'" & TextBoxJop.Text & "' ,'" & DateTimePickerAppoiment.Text & "','" & TextBoxClass.Text & "','" & DateTimePickerBirthday.Text & "' ,'" & DateTimePickerEnd_date.Text & "' ,'" & TextBoxEnd_class.Text & "','" & TextBoxEnd_for.Text & "' ,'" & TextBoxNote.Text & "')" executquery() con.Close() MsgBox("Your Data Inserted") Catch ex As Exception MsgBox("Your Data Not Inserted") End Try TechersDataGridView.DataSource = TechersBindingSource End Sub
Что я уже пробовал:
Public Sub executquery() Dim commandOleDb As New OleDbCommand(query, con) commandOleDb.ExecuteNonQuery() con.Close() End Sub Private Sub ButtonInsert_Click(sender As Object, e As EventArgs) Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Almaashat.accdb") Dim query As String Try con.Open() query = "INSERT INTO Techers (File_ID,Name,Workplace,Jop,Appointment,Class,Birthday,End_date,End_class,End_for,Note) VALUES (" & TextBoxFile_ID.Text & " ,'" & TextBoxName.Text & "' ,'" & TextBoxWorkplace.Text & "' ,'" & TextBoxJop.Text & "' ,'" & DateTimePickerAppoiment.Text & "','" & TextBoxClass.Text & "','" & DateTimePickerBirthday.Text & "' ,'" & DateTimePickerEnd_date.Text & "' ,'" & TextBoxEnd_class.Text & "','" & TextBoxEnd_for.Text & "' ,'" & TextBoxNote.Text & "')" executquery() con.Close() MsgBox("تم الإدخال بنجاح") Catch ex As Exception MsgBox("لم يتم الإدخال بنجاح") End Try TechersDataGridView.DataSource = TechersBindingSource End Sub