Log in the form of the form

xiaoxiao2021-03-06  57

File → New → Project Select Windows Applications and add 2 Label controls on the form, 2 TextBox controls, 2 buton controls

After the interface is designed, the write code is written in the Button's Click event is as follows:

(At the top of the program referenced Imports System.Data.OleDb) Private Sub BOk_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BOk.Click 'defined Dim olecn As New OleDbConnection ( "Provider = Microsoft.Jet.OLEDB .4.0; Data Source = Data.mdb ") Dim olecm as New OleDbCommand (" select * from Login ", olecn) Dim olead as New OleDbDataAdapter Dim olerd as OleDbDataReader Dim pd as Boolean = False 'is defined as a boolean error processing later use Dim I as integer OLECM = New OLEDBCOMMAND ("Select * from login", OLECN "and database establishment connection OLECN.OPEN () OLERD = OLECM.EXECUTEREADER 'loop judgment and database in the database DO while OLERD.READ () for i = 0 to OLERD.FIELDCOUNT - 1 if Trim (Tuser.Text) = (Olerd.Item ("Account")) And Trim (TPASSWORD.TEXT) = (Olerd.Item ("Password")) THEN MSGBOX ("successfully login ") PD = True EXIT SUB end if next loop tuser.text =" "tpassword.text =" " Tuser.focus () OLERD.CLOSE () Olecn.close () End Sub

Finish

转载请注明原文地址:https://www.9cbs.com/read-112920.html

New Post(0)