本文介绍了如何使用Access值为登录窗口编写代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用访问表值登录到应用程序的代码是什么????请帮助我!

what is the code for the login into the application by using access table values???Please help me!!!

推荐答案

Dim ConnectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Data.accdb" '{Data.accdb} Database File name
Dim Conn As New OleDb.OleDbConnection(ConnectionString) ' Create New Connection To Database

Private Sub BtnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnLogin.Click
    Dim Command As New OleDb.OleDbCommand("", Conn) 'Create Command To Read Data From Database
    ''''''''''''''''''''''''''''''''''
    Command.CommandText = "SELECT * FROM Users WHERE uName = '" & TxtUsername.Text & "' AND  Pass = '" & TxtPass.Text & "'"
    'Users ' Table Name
    'uName Is Username Column Name
    'Pass Is Password Column Name
    ''''''''''''''''''''''''''''''''''
    Conn.Open() 'Open Database
    If Command.ExecuteReader.HasRows Then ' If There Are Any Value Returned From Command
        MsgBox("Login Successful")
    Else
        MsgBox("Login Filed")
    End If
    Conn.Close() 'Close Database
End Sub


这篇关于如何使用Access值为登录窗口编写代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 13:45