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

SQL Database Operations in VB.NET

This code defines a class for connecting to a SQL database and performing CRUD operations. It establishes a connection to a SQL database, defines commands to insert and select data from two tables, and includes event handler methods for buttons to save, cancel, add new data, find data, delete data, and close the application. Data is bound to two data grids for display.

Uploaded by

Auranda Qolfi
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)
14 views2 pages

SQL Database Operations in VB.NET

This code defines a class for connecting to a SQL database and performing CRUD operations. It establishes a connection to a SQL database, defines commands to insert and select data from two tables, and includes event handler methods for buttons to save, cancel, add new data, find data, delete data, and close the application. Data is bound to two data grids for display.

Uploaded by

Auranda Qolfi
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

Imports System.

Data
Imports [Link]

Public Class WindowsApplication1


Public koneksi As String
Public sql1, sql2 As String
Public conn As [Link] = Nothing
Public cmd As [Link] = Nothing
Public dtadapter As New [Link]
Public dttable As New DataTable

Private Sub WindowsApplication1_Load(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]
'PERINTAH KONEKSI DATABASE DISIMPAN 1 BARIS
koneksi = "Data Source=ACER;Initial Catalog=fahlefi;Integrated Security=True"
conn = New [Link](koneksi)
[Link]()
End Sub
Sub simpan()
'PERINTAH sql1 DISIMPAN 1 BARIS
sql1 = "Insert into Table_1 values('" & [Link] & "','" &
[Link] & "','" & [Link] & "','" & [Link] & "')"
cmd = New [Link](sql1)
[Link] = conn
[Link]()
End Sub
Sub REZAGEGEH()
sql1 = "select * from dbo.Table_1"
dtadapter = New SqlDataAdapter(sql1, conn)
Dim gegeh As New DataTable
[Link]()
[Link](gegeh)
[Link] = gegeh
End Sub
Sub simpan2()
'PERINTAH sql1 DISIMPAN 1 BARIS
sql2 = "Insert into Table_2 values('" & [Link] & "','" &
[Link] & "')"
cmd = New [Link](sql2)
[Link] = conn
[Link]()
End Sub
Sub REZAGEGEHBANGET()
sql2 = "select * from dbo.Table_2"
dtadapter = New SqlDataAdapter(sql2, conn)
Dim gegehbanget As New DataTable
[Link]()
[Link](gegehbanget)
[Link] = gegehbanget
End Sub

Private Sub btsave_Click(ByVal sender As [Link], ByVal e As [Link])


Handles [Link]
simpan()
REZAGEGEH()
simpan2()
REZAGEGEHBANGET()
MsgBox("Data Sudah Disimpan", [Link],
"Perhatian")
End Sub

Private Sub btcancel_Click(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]

MsgBox("Data Sudah Dibatalkan", [Link], "Perhatian")

End Sub

Private Sub btnew_Click(ByVal sender As [Link], ByVal e As [Link])


Handles [Link]

MsgBox("Data Baru", [Link], "Perhatian")

End Sub

Private Sub btFind_Click(ByVal sender As [Link], ByVal e As [Link])


Handles [Link]

End Sub

Private Sub btDelete_Click(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]

MsgBox("Data Telah Dihapus", [Link], "Perhatian")

End Sub

Private Sub btclose_Click(ByVal sender As [Link], ByVal e As [Link])


Handles [Link]
[Link]()

End Sub

Private Sub ComboBox1_SelectedIndexChanged(sender As [Link], e As


[Link])

End Sub
End Class

You might also like