Sie sind auf Seite 1von 2

Imports System.

Data
Imports System.Data.SqlClient
Imports System.Data.Odbc

Public Class FormLogin


Dim odcon As New Odbc.OdbcConnection
Dim odcommand As New Odbc.OdbcCommand
Dim odadapter As New Odbc.OdbcDataAdapter
Dim oddataread As Odbc.OdbcDataReader
Dim oddataset As New DataSet

Dim read As SqlDataReader


Dim ds As New DataSet
Dim dt As New DataTable
Dim da As New SqlDataAdapter
Dim cn As New SqlClient.SqlConnection("Data Source=USER-PC\SQLEXPRESS;Initia
l Catalog=Pharmacy;Integrated Security=True")
Dim cm As New SqlClient.SqlCommand
Dim count As Integer = 0
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.E
ventArgs) Handles btnexit.Click
'btnExit
Dim Message As String = "Are you sure that you want to exit?"
Dim Titlebar As String = "Attention"
Dim Buttons As Integer = MessageBoxButtons.YesNo
Dim Result As DialogResult
'Display a MessageBox before exit
Result = MessageBox.Show(Me, Message, Titlebar, MessageBoxButtons.YesNo,
_
MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)
'Gets the result of the MessageBox display
If Result = Windows.Forms.DialogResult.Yes Then
'Closes the parent form
Application.Exit()
End If
End Sub
Private Sub btnlogin_Click(ByVal sender As System.Object, ByVal e As System.
EventArgs) Handles btnlogin.Click
odcon.ConnectionString = "Dsn=pg;database=postgres;server=192.168.1.6;po
rt=5432;uid=postgres;pwd=abc"
odcon.Open()
odcommand = New OdbcCommand("SELECT staff_id,staff_password FROM staff_i
nfo WHERE staff_id = '" & txtName.Text & "'", odcon)
odcommand.ExecuteNonQuery()
oddataread = odcommand.ExecuteReader
If oddataread.HasRows Then
oddataread.Read()
If txtpswrd.Text = oddataread.Item("staff_password") Then
FormMenu.Show()
Me.Hide()

Else
MessageBox.Show("Wrong password, please input correct password",
"MEMBER LOGIN", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, 0, 0)
txtpswrd.Text = ""
End If
odcon.Close()
Else
MessageBox.Show("Username not registered", "MEMBER LOGIN", MessageBo
xButtons.OK, MessageBoxIcon.Exclamation, 0, 0)
odcon.Close()
txtpswrd.Text = ""
txtName.Text = ""
End If

Das könnte Ihnen auch gefallen