帮忙看看哪有错,登陆不进去
来源:互联网 发布:美军网络战司令部 编辑:程序博客网 时间:2024/04/28 06:28
Public Class DBUser
Private _UserName As String
Private _Password As String
Private _RealName As String
Private _Memo As String
Property UserName() As String
Get
Return _UserName
End Get
Set(ByVal value As String)
_UserName = value
End Set
End Property
Property Password() As String
Get
Return _Password
End Get
Set(ByVal value As String)
_Password = value
End Set
End Property
Property RealName() As String
Get
Return _RealName
End Get
Set(ByVal value As String)
_RealName = value
End Set
End Property
Property Memo() As String
Get
Return _Memo
End Get
Set(ByVal value As String)
_Memo = value
End Set
End Property
Sub New(ByVal Name As String, ByVal PWD As String)
_UserName = Name
_Password = PWD
End Sub
Function LoginConfirm() As Boolean
Dim SQLString As String
SQLString = "SELECT * FROM tbUser WHERE UserName = ' " & _UserName & " ' AND Password ='" & _Password & "'"
'SQL查询语句
Dim UserTable As DataTable = DBOperation.DBOperate(SQLString)
If UserTable.Rows.Count < 1 Then '判断用户是否存在
MsgBox("输入用户名或密码有误,请重试", MsgBoxStyle.Exclamation, "信息框")
Return False
Else
'判断用户密码是否正确
' _RealName = UserTable.Rows(0)("RealName")
' _Memo = UserTable.Rows(0)("Memo")
Return True
End If
End Function
Function AddUser(ByVal User As DBUser) As Boolean
Dim SQLString As String
SQLString = "SELECT * tbUser WHERE UserName='" & User.UserName & "'AND Password='" & User.Password & "'"
Dim UserTable As DataTable = DBOperation.DBOperate(SQLString)
If UserTable.Rows.Count >= 1 Then '判断用户是否存在
MsgBox("输入的用户名已存在,请重试", MsgBoxStyle.Exclamation, "信息框")
Return False
Else
SQLString = "INSERT INTO tbUser VALUES('" & User.UserName & "','" & User.Password & "','" & User.RealName & "','" & User.Memo & "')"
DBOperation.DBOperate(SQLString)
Return True
End If
End Function
Sub DelUser(ByVal DeleteUserName As String)
Dim SQLString As String
SQLString = "DELETE FROM tbUser WHERE UserNAME='" & DeleteUserName & "'"
DBOperation.DBOperate(SQLString)
End Sub
Function PasswordModify(ByVal NewPassword As String) As Boolean
Dim SQLString As String
SQLString = "UPDATE tbUser SET[Password]='" & NewPassword & "' WHERE UserName='" & _UserName & "'"
DBOperation.DBOperate(SQLString)
End Function
Shared Function AttachCode() As String
Dim TempCode As String = ""
Dim randomvalue As Integer
Dim i As Integer
Randomize()
For i = 1 To 5
randomvalue = CInt(Int((90 - 65 + 1) * Rnd() + 65))
TempCode = TempCode + Chr(randomvalue)
Next
Return TempCode
End Function
End Class
Public Class DBOperation
Shared Function DBOperate(ByVal SQLString As String) As DataTable
Try
'Dim path As String = Application.StartupPath
Dim CONN As String = "provider=microsoft.jet.oledb.4.0;data source=" + Application.StartupPath + "/app_data/db.mdb"
Dim oleconn As New OleDb.OleDbConnection(CONN)
Dim cmd As OleDb.OleDbCommand = New OleDb.OleDbCommand(SQLString, oleconn)
cmd.CommandType = CommandType.Text
Dim sTokens() As String
sTokens = SQLString.Split(" ")
If Strings.InStr("INSERT,DELETE,UPDATE", sTokens(0).ToUpper) Then
If oleconn.State <> ConnectionState.Open Then
oleconn.Open()
End If
cmd.ExecuteNonQuery()
If oleconn.State <> ConnectionState.Closed Then
oleconn.Close()
End If
If sTokens(0).ToUpper = "INSERT" Then
'MsgBox("插入记录成功!", MsgBoxStyle.Exclamation, "信息框")
End If
If sTokens(0).ToUpper = "DELETE" Then
MsgBox("删除记录成功!", MsgBoxStyle.Exclamation, "信息框")
End If
If sTokens(0).ToUpper = "UPDATE" Then
'MsgBox("更新记录成功!", MsgBoxStyle.Exclamation, "信息框")
End If
Return Nothing
Else
Dim ObjectdsDataSet As New DataSet
Dim adapter As New OleDb.OleDbDataAdapter()
adapter.TableMappings.Add("Table", "TEMP")
adapter.SelectCommand = cmd
If oleconn.State <> ConnectionState.Open Then
oleconn.Open()
End If
cmd.ExecuteNonQuery()
If oleconn.State <> ConnectionState.Closed Then
oleconn.Close()
End If
adapter.Fill(ObjectdsDataSet)
Return ObjectdsDataSet.Tables("TEMP")
End If
Catch
MsgBox(Err.Description)
End Try
End Function
End Class
Option Strict Off
Option Explicit On
Imports System.Data.OleDb
Imports System.Xml
Friend Class login
Inherits System.Windows.Forms.Form
Private Sub txtname_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ErrorProvider1.SetError(TextBox1, "")
ErrorProvider1.SetError(TextBox2, "")
If TextBox1.Text = "" Then
ErrorProvider1.SetError(TextBox1, "必须输入用户名!")
TextBox1.Focus()
Exit Sub
End If
If TextBox2.Text = "" Then
ErrorProvider1.SetError(TextBox2, "必须输入密码!")
TextBox2.Focus()
Exit Sub
End If
Dim user As New DBUser(Trim(TextBox1.Text), TextBox2.Text)
If user.LoginConfirm = True Then
main.Show()
Else
MsgBox("输入错误,请重试", MsgBoxStyle.Exclamation, "信息框")
Exit Sub
End If
Me.Hide()
End Sub
Private Sub TextBox2_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox2.KeyDown
If e.KeyCode = Keys.Enter Then
Dim user As New DBUser(Trim(TextBox1.Text), TextBox2.Text)
If user.LoginConfirm Then
main.Show()
Else
MsgBox("输入错误,请重试", MsgBoxStyle.Exclamation, "信息框")
Exit Sub
End If
Me.Hide()
Else
Exit Sub
End If
End Sub
Private Sub NotifyIcon1_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
If (Me.Visible) Then
Me.Visible = False
Else
Me.Visible = True
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Close()
End Sub
Private Sub login_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Focus()
End Sub
End Class
- 帮忙看看哪有错,登陆不进去
- C#编写的这段代码运行不出来,帮忙看看是哪里有错?感激不尽。。。
- 写的一个文件加密程序,帮忙看看哪有错啊
- asp登陆问题,大神帮忙看看!
- 用户后台登陆不进去原因
- Ubuntu登陆不进去(已解决)
- Ubuntu登陆不进去(已解决)
- Ubuntu登陆界面循环登陆不进去(已解决)
- 帮忙看看
- 帮忙看看。。。。
- 【当你学不进去的时候】----看看这个
- 淘宝网登陆时密码输不进去??
- 虚拟机下图形模式登陆不进去的问题
- magento安装好之后后台登陆不进去的解决方法
- ArcGIS Server 管理器登陆不进去的问题
- 修改完MySql密码后,phpmyadmin登陆不进去
- oracle 登录时提示无监听登陆不进去
- 腾讯云账号的root登陆不进去
- mongodb 使用 - basic
- SQL 测验
- 《Spring技术内幕——深入解析Spring架构与设计原理》连载2
- [转]C++中的指针--智能指针
- 常用首页JS图片切换特效
- 帮忙看看哪有错,登陆不进去
- C# 线程注入和DLL注入
- 【转】JPDA:Java平台调试架构(常用的远程调试方法)
- 如何升级oracle的client
- SAX---SIMPLE API FOR XM
- 久违的重逢
- OpenCV 学习 (1)
- Spring中的bean和BeanFactory
- symbian 程序之间通迅方法之一