In the VB version in the forum, some friends often saw questions about landing. This article specializes in providing some help for beginners, and of course, I hope to give a guidance for a better way.
First File → New → Project Select Windows Applications and add 2 Label controls on the form, 2 TextBox controls, 2 Buton controls are shown below (1-1):
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
The whole process is finished.
QQ: 174453914