當前位置:編程學習大全網 - 遊戲軟體 - 誰能幫我做壹個VB連接access數據庫的用戶登錄源代碼,要可以註冊的

誰能幫我做壹個VB連接access數據庫的用戶登錄源代碼,要可以註冊的

Private Sub Command1_Click()

Dim A As String

A = App.Path + "\ACCESS文件.mdb"

Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & A & ";Persist Security Info=False"

Adodc1.RecordSource = "SELECT * FROM 用戶表 WHERE 用戶名='" + 用戶名 + "' AND 密碼='" + 密碼 + "'"

Adodc1.Refresh

If OT Adodc1.Recordset.EOF Then

主切面.Show

Me.Hide

Else

MsgBox ("用戶名或密碼錯誤!請重新輸入!")

Me.用戶名 = ""

Me.密碼 = ""

'清空文本框內容

End If

End Sub

' 上面是登陸,把ACCESS建立在VB工程壹個文件夾裏取相對的路徑

下面是註冊用戶表:

Private Sub Command2_Click()

Dim A As String

A = App.Path + "\ACCESS文件.mdb"

Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & A & ";Persist Security Info=False"

Adodc1.RecordSource = "SELECT * FROM 用戶表 "

Adodc1.Refresh

If OT Adodc1.Recordset.EOF Then

Adodc1.recordset.AddNew

Adodc1.recordset.fields("用戶名")=文本框1

Adodc1.recordset.fields("密碼")=文本框2

.....................

Adodc1.recordset.update

文本框1=""

文本框2=""

......

文本框1.setfocus

ELSE

文本框1=""

文本框2=""

.....

文本框1.setfoucus

end if

end sub

  • 上一篇:《黑白禁區》有多少集?
  • 下一篇:汽車小白如何購買新車或二手車?
  • copyright 2024編程學習大全網