Public strSQL As String
Public con As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\Database.mdb;Persist Security Info=False;" '
Public oledbcon As New OleDbConnection(con)
Public da As OleDbDataAdapter
Public ds As DataSet
login file Code (VBScript)
Option Explicit On
Option Strict On
Imports System.Data
Imports System.Data.OleDb
Public Class LoginForm
Inherits System.Windows.Forms.Form
Dim Conn As OleDbConnection
Dim da As OleDbDataAdapter
Dim ds As New DataSet
Dim comboard As OleDbCommand
Dim IsFind As Boolean = False
Dim ToClose As Boolean = False
Dim OleReader As OleDbDataReader
Dim UserIDA As String
Dim PassIDA As String
Dim lvIDA As String
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
Conn = New OleDbConnection
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = con
.Open()
End With
If UsernameTextBox.Text = "" Then
MessageBox.Show("ใส่ข้อมูล ผู้ใช้เข้าสู่ระบบ ", "UserID", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
Dim SqlSelect As String = ""
SqlSelect = "select * from USERLOGIN Where username = " & "'" & UsernameTextBox.Text & "'"
Dim OleCommand As New OleDbCommand(SqlSelect, Conn)
OleReader = OleCommand.ExecuteReader
OleReader.Read()
UserIDA = CStr(OleReader.Item("username"))
PassIDA = CStr(OleReader.Item("password"))
Conn.Close()
If UsernameTextBox.Text = UserIDA And PasswordTextBox.Text = PassIDA Then
Form1.Show()
'UsernameTextBox.Text = ""
rUserName = UsernameTextBox.Text
rAcc_pass = PasswordTextBox.Text
UsernameTextBox.Text = ""
Me.Hide()
Else
MessageBox.Show("กรุณาใส่ข้อมูลให้ถูกต้อง", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
End Sub
Private Sub ReadMyData(ByVal con As String)
Throw New NotImplementedException
End Sub
End Class