0% found this document useful (0 votes)
40 views2 pages

Using Using Using Using Using Using Using Using Using Using Namespace Public Partial Class New

The document defines a Windows Forms application that connects to an Access database and inserts new records. It imports namespaces for Windows Forms, OLEDB, and other .NET classes. A form class is defined that connects to a database file and handles a button click event to insert a new record into a table with the values from two text boxes for name and stock. A message is displayed to confirm the data was saved.

Uploaded by

AyuAnitaII
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views2 pages

Using Using Using Using Using Using Using Using Using Using Namespace Public Partial Class New

The document defines a Windows Forms application that connects to an Access database and inserts new records. It imports namespaces for Windows Forms, OLEDB, and other .NET classes. A form class is defined that connects to a database file and handles a button click event to insert a new record into a table with the values from two text boxes for name and stock. A message is displayed to confirm the data was saved.

Uploaded by

AyuAnitaII
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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)


{

}
}
}

You might also like