Here is my code:
Imports System.Data.SqlClient
Public Class Form1
Dim iConnect As SqlConnection
Dim iCmd As SqlCommand
Dim iRdr As SqlDataReader
Private Sub dologin()
iConnect = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\UserData.mdf;Integrated Security=True;User Instance=True")
iConnect.Open()
Dim strLogin As String = "SELECT username, password FROM tableusername WHERE username = '" & userbox.Text & "' AND password = '" & passbox.Text & "'"
iCmd = New SqlCommand(strLogin, iConnect)
iRdr = iCmd.ExecuteReader
If iRdr.Read = True Then
iRdr.Close()
iConnect.Close()
Dim absen As String = "INSERT INTO tanggal(date) values(getdate())"
iCmd = New SqlCommand(absen, iConnect)
iConnect.Open()
iCmd.ExecuteNonQuery()
MsgBox("Berhasil!")
Else
MsgBox("Gagal Maning")
End If
End Sub
Private Sub absen_b_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles absen_b.Click
dologin()
End Sub
End Class
Is there anything wrong with it?