Imports System.Data.OleDb
Imports System.Data
Public Class frmLogin
Inherits System.Windows.Forms.Form
Dim constr As String = "Provider=Microsoft.jet.OLEDB.4.0;Data source=C:\DatabaseSell.mdb"
Dim conn As OleDbConnection
Dim ds As New DataSet
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MyCmd As OleDbCommand
Dim str As String
Dim intNumRows As Integer
str = "SELECT * FROM Employee WHERE EName = '" & Me.txtUsername.Text & "' AND EPassword = '" & Me.txtPassword.Text & "' "
MyCmd = New OleDbCommand(str, conn)
MyCmd.ExecuteNonQuery()
ds.Tables("DatabaseSell").Clear()
Showee()
If intNumRows = 0 Then >>>> ตรงนี้อ่าคับ<<<<
txtUsername.Text = ""
txtUsername.Focus()
FrmIndex.Show()
Me.Hide()
Else
MessageBox.Show("Username or Password Incorrect")
End If
conn.Close()
conn = Nothing
End Sub
Private Sub frmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
conn = New OleDbConnection(constr)
conn.Open()
Showee()
End Sub
Sub Showee()
Dim strsQL As String = "SELECT * FROM Employee ORDER BY EID ASC "
Dim objAdapter As New OleDbDataAdapter(strsQL, conn)
objAdapter.Fill(ds, "DatabaseSell")
Dim objDataview As New DataView(ds.Tables("DatabaseSell"))
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub
End Class