Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Data.OleDb;
- using System.Data;
- using System.Windows.Forms;
- namespace WindowsFormsApplication1
- {
- class Broker
- {
- OleDbConnection connection;
- OleDbCommand command;
- private void ConnectTo()
- {
- connection = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\student\Desktop\Database181.accdb");
- command = connection.CreateCommand();
- }
- public Broker()
- {
- ConnectTo();
- }
- public void Insert(Person p)
- {
- try
- {
- command.CommandText = "INSERT INTO Movies([Zaglavie], [Janr], [Glavnarolq], [Glavnq_rolq]) VALUES ('" + p.Title1 + "', '" + p.janr1 + "', '" + p.rolq1 + "', '" + p.rolq2 + "')";
- command.CommandType = CommandType.Text;
- connection.Open();
- command.ExecuteNonQuery();
- }
- catch (Exception)
- {
- MessageBox.Show("Некоректни данни! Моля въведете отново!");
- }
- finally
- {
- if (connection != null)
- {
- connection.Close();
- }
- }
- }
- public void Delete(Person p)
- {
- try
- {
- command.CommandText = "DELETE FROM Movies([Zaglavie], [Janr], [Glavnarolq], [Glavnq_rolq]) WHERE ('" + p.Title1 + "', '" + p.janr1 + "', '" + p.rolq1 + "', '" + p.rolq2 + "')";
- command.CommandType = CommandType.Text;
- connection.Open();
- command.ExecuteNonQuery();
- }
- catch (Exception)
- {
- MessageBox.Show("Некоректни данни! Моля въведете отново!");
- }
- finally
- {
- if (connection != null)
- {
- connection.Close();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment