using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;

namespace Example_of_database
{
    public partial class frmadd : Form
    {
        public frmadd()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                OleDbConnection conn = new OleDbConnection();
                conn.ConnectionString = @"provider=microsoft.jet.oledb.4.0;" + @"data source=db1.mdb";
                conn.Open();
                OleDbCommand cmd = new OleDbCommand();
                cmd.Connection = conn; cmd.CommandText = "insert into phone ([Name],[Family],[Phone])values(@Name,@Family,@Phone)";
                cmd.Parameters.AddWithValue("@Name", txtname.Text);
                cmd.Parameters.AddWithValue("@Family", txtfamily.Text);
                cmd.Parameters.AddWithValue("@Phone", long.Parse(txtphone.Text));
                cmd.ExecuteNonQuery();
                this.Close();
                
            }
            catch
            {
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
