vb.net登陆验证 vb登录界面代码

VB.Net 怎么验证 SQL2008 数据库的ID与密码基础类库:
Imports Microsoft.VisualBasic
'执行Access语句的封装类 。
Public Class AccessExecClass
Private conn As Data.OleDb.OleDbConnection
Private cmd As Data.OleDb.OleDbCommand
'创建类对象,并连接到数据库 。
Sub New()
If openAccess Then
Else
msgbox("open Access Fail.")
End If
End Sub
'创建类对象 , 并连接到数据库 。'输入带目录名称的数据库文件名称:dbFileName,例如:“\DB数据库\企业数据库.aspx”
Sub New(ByVal dbFileName As String)
If OpenAccess(dbFileName) Then
Else
MsgBox("open Access Fail.")
End If
End Sub
Function OpenAccess() As Boolean
OpenAccess = False
'检验用户的帐号密码是否正确
Dim provider As String '= ConfigurationManager.ConnectionStrings("ConnectionString").ProviderName
provider = "Provider=Microsoft.Jet.OLEDB.4.0"
Dim database As String
database = "Data Source="System.Web.HttpContext.Current.Server.MapPath("\数据库.aspx")";Persist Security Info=true"
conn = New Data.OleDb.OleDbConnection(provider";"database)
conn.Open()
OpenAccess = True
End Function
Function OpenAccess(ByVal dbFileName As String) As Boolean
OpenAccess = False
'检验用户的帐号密码是否正确
Dim provider As String '= ConfigurationManager.ConnectionStrings("ConnectionString").ProviderName
provider = "Provider=Microsoft.Jet.OLEDB.4.0"
Dim database As String
database = "Data Source="System.Web.HttpContext.Current.Server.MapPath(dbFileName)";Persist Security Info=true"
conn = New Data.OleDb.OleDbConnection(provider";"database)
conn.Open()
OpenAccess = True
End Function
'关闭数据库 。
Sub CloseAccess()
cmd = Nothing
conn.Close()
End Sub
'执行一条Access语句,执行成功就返回True 。
Function ExecAccessString(ByVal AccessStr As String) As Boolean
cmd = New Data.OleDb.OleDbCommand(AccessStr, conn)
cmd.ExecuteNonQuery()
'Dim aa As Data.OleDb.OleDbDataReader = cmd.ExecuteReader
ExecAccessString = True
End Function
'返回读取到的数据,注意是用地址传递方式返回
Sub ExecAccessString(ByVal AccessStr As String, ByRef AccessReader As Data.OleDb.OleDbDataReader)
cmd = New Data.OleDb.OleDbCommand(AccessStr, conn)
cmd.ExecuteNonQuery()
AccessReader = cmd.ExecuteReader
End Sub
End Class
登陆代码:
Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
Dim wl As New WebLog'用户登录记录开始 , 仅对购买了Log 功能的用户,才开放此功能 , 否则不会实际记录Log
Dim sql As String
Dim aDB As New AccessExecClass
Dim mypw As String
Label1.Visible = False
Label2.Visible = False
Label3.Visible = False
Label4.Visible = False
'没有输入时,不能进行登陆
If TextBox1.Text = "" Then
Label1.Visible = True
Return
End If
If TextBox2.Text = "" Then
Label2.Visible = True
Return
End If
If TextBox3.Text = "" Then
Label3.Visible = True
Return
End If
If TextBox3.Text = TextBox4.Text Then
Else
Label3.Visible = True
Return
End If
Dim iRnd As Integer = Rnd(10) * 100
TextBox3.Text = ""
TextBox4.Text = iRnd.ToString
'Dim iRnd As Integer = Rnd(10) * 100
'注意:此处需要加入防止注入分析,包含'的肯定是特别语句,讲拒绝.
If TextBox1.Text.IndexOf("'")0 Or TextBox2.Text.IndexOf("'")0 Then
TextBox1.Text = "不能输入非法字符,将强制清空"
TextBox2.Text = ""
Else
Dim pw As New MD5EnCode(13, 19)' '2次加密

推荐阅读