Private Sub InsertInDB()
Dim conn As New OleDb.OleDbConnection
Dim comm As New OleDb.OleDbCommand
'Insert in DB1
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\Data\4RegelsTekst.mdb"
comm.Connection = conn
comm.CommandText = "INSERT INTO 4Regels-Tekst (EtiketCode,Regel1,Regel2,Regel3,Regel4,Klantnaam) VALUES ('" txtCode.Text & "','" & txtRegel1.Text & "','" & txtRegel2.Text & "','" & txtRegel3.Text & "','" & txtRegel4.Text & & "','" & txtKlantnaam.Text & "')"
Try
conn.Open()
comm.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.ToString)
Finally
conn.Close()
End Try
'Insert in DB_Backup
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\Backup\4RegelsTekst.mdb"
comm.Connection = conn
comm.CommandText = "INSERT INTO 4Regels-Tekst (EtiketCode,Regel1,Regel2,Regel3,Regel4,Klantnaam) VALUES ('" & txtCode.Text & "','" & txtRegel1.Text & "','" & txtRegel2.Text & "','" & txtRegel3.Text & "','" & txtRegel4.Text & & "','" & txtKlantnaam.Text & "')"
Try
conn.Open()
comm.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.ToString)
Finally
conn.Close()
End Try
End Sub
Private Sub DeleteFromDB()
Dim conn As New OleDb.OleDbConnection
Dim comm As New OleDb.OleDbCommand
'Delete from DB1
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\Data\4RegelsTekst.mdb"
comm.Connection = conn
comm.CommandText = "DELETE FROM 4Regels-Tekst WHERE (EtiketCode='" & txtCode.Text & "')"
Try
conn.Open()
comm.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.ToString)
Finally
conn.Close()
End Try
End Sub
Private Sub UpdateDB()
Dim conn As New OleDb.OleDbConnection
Dim comm As New OleDb.OleDbCommand
'Update DB1
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\Data\4RegelsTekst.mdb"
comm.Connection = conn
comm.CommandText = "UPDATE 4Regels-Tekst SET Regel1='" & txtRegel1.Text & "', Regel2=" & txtRegel2.Text & "', Regel3='" & txtRegel3.Text & "', Regel4='" & txtRegel1.Text & "', Klantnaam='" & txtKlantnaam.Text & "' WHERE (EtiketCode='" & txtCode.Text & "')"
Try
conn.Open()
comm.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.ToString)
Finally
conn.Close()
End Try
End Sub