You are on page 1of 2

using System;

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

namespace barang
{
public partial class Form1 : Form
{
OleDbConnection connect = new
OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:\Users\user\Documents\Visual Studio
2013\Projects\barang\barang\database\barang\dbBarang.mdb");
public Form1()
{
InitializeComponent();
}

private void label2_Click(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
connect.Open();
OleDbCommand command = new OleDbCommand();
command.CommandText = ("Insert INTO dbBarang (Nama_Barang, Stock) Values ('" +
textBoxNamaBarang.Text + "','" + textBoxStock.Text + "')");

command.Connection = connect;
command.ExecuteNonQuery();
connect.Close();

MessageBox.Show("Data Telah Tersimpan");

}

private void textBox2_TextChanged(object sender, EventArgs e)
{

}
}
}