Imports System.Data.OleDb
Imports System.Data
Public Class frmfind
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFind.Click, btnFind.Click
Dim objConn As New OleDbConnection
Dim objCmd As New OleDbCommand
Dim strConnString, strSQL As String
Dim directory As String = My.Application.Info.DirectoryPath
strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & directory & "\database.mdb;Jet OLEDB:Database Password=;"
objConn.ConnectionString = strConnString
objConn.Open()
Dim intNumRows As Integer
strSQL = "SELECT COUNT(*) FROM stinfo WHERE StudentID = '" & Me.txtSTID.Text & "' "
objCmd = New OleDbCommand(strSQL, objConn)
intNumRows = objCmd.ExecuteScalar()
If intNumRows > 0 Then
Dim frm As New frmMain
frm._strUser = Me.txtSTID.Text
frm.LoadInfor()
frm.Show()
Me.Hide()
Else
MessageBox.Show("ไม่พบรหัสประจำตัวนักเรียน")
End If
objConn.Close()
objConn = Nothing
End Sub