Aplikasi Sederhana di VB .Net 2008

Ok, kali ini saya mau share bikin aplikasi sederhana di Visual Studio 2008, tepatnya Visual Basic.

Aplikasi ini menyimpan data ke database dan menampilkannya pada datagrid…

Langsung aja, ini saya share scriptnya dulu ya… \:D/

Imports System.Data.OleDb
Imports System.Data.Odbc
Imports System.Data

Public Class databuku

Private Sub Simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call Konek()
CMD = New OleDbCommand(“insert into data_buku(Judul_buku,kategori,penerbit,penulis,jumlah_buku)values( ‘” & TextBox1.Text & “‘,'” & TextBox2.Text & “‘,'” & TextBox3.Text & “‘,'” & TextBox4.Text & “‘,” & TextBox5.Text & “)”, CONN)
CMD.ExecuteNonQuery()

TextBox1.Text = “”
TextBox2.Text = “”
TextBox3.Text = “”
TextBox4.Text = “”
TextBox5.Text = “”

Call Konek()

DA = New OleDbDataAdapter(“SELECT * FROM data_buku”, CONN)
DS = New DataTable
DS.Clear()
DA.Fill(DS)
DataGridView1.DataSource = DS
End Sub

Private Sub databuku_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call Konek()

DA = New OleDbDataAdapter(“SELECT * FROM data_buku”, CONN)
DS = New DataTable
DS.Clear()
DA.Fill(DS)
DataGridView1.DataSource = DS
End Sub
End Class

Met nyobain ya…

Tagged: , , ,

Comments are closed.