Professional Documents
Culture Documents
Kinematika
Kinematika
SqlClient
Public Class Form1
Dim str As String
Dim con As SqlConnection
Function checkkd(str As String) As Boolean
Dim query As String = "select count(*) from tbl_pelanggan where kd ='" &
txtkd.Text & "'"
Dim cmd As New SqlCommand(query, con)
Return cmd.ExecuteScalar()
End Function
Sub koneksi()
Try
str = "data source =ALLWIN7PC-PC;initial catalog =tetx;integrated
security=true"
con = New SqlConnection(str)
con.Open()
Catch ex As Exception
End Try
End Sub
Else
MsgBox("tdkbisa")
End If
End If
Catch ex As Exception
End Try
End Sub
Call koneksi()
End Sub
Private Sub btndelete_Click(sender As Object, e As EventArgs) Handles btndelete.Click
Try
If checkkd(txtkd.Text) Then
Dim cmd As New SqlCommand("delete from tbl_pelanggan where kd = '" &
txtkd.Text & "'", con)
cmd.ExecuteNonQuery()
MessageBox.Show("deleted")
txtalamat.Text = ""
txtcontact.Text = ""
txtkd.Text = ""
txtket.Text = ""
txtnama.Text = ""
Else
MsgBox("undel")
End If
Catch ex As Exception
End Try
End Sub
End Try
End Sub
End Class