'---------------------------
'输入信息验证
'---------------------------
Dim id As String
Dim pwd As String
id = Trim(txtUserID.Text)
pwd = Trim(txtUserPwd.Text)
If id = "" Then
MsgBox "请输入用户名!", vbExclamation, "警告"
txtUserID.SetFocus
Exit Sub
End If
If pwd = "" Then
MsgBox "请输入密码!", vbExclamation, "警告"
txtUserPwd.SetFocus
Exit Sub
End If
'---------------------------
'操作员身份验证
'---------------------------
Dim sql As String
Dim rs As ADODB.Recordset
sql = "select o_name, o_id, o_pwd, o_stau from co_info where o_id='" & id & "'"
On Error GoTo err1
Set rs = sys.objconn.Execute(sql)
If rs.BOF And rs.EOF Then '用户名不存在
MsgBox "用户名或密码错误!", vbExclamation, "警告"
txtUserID.Text = ""
txtUserPwd.Text = ""
txtUserID.SetFocus
Else '用户名存在
If rs(1) = id And rs(2) = pwd Then '密码正确
logName = rs(0)
logStau = rs(3)
sysLogin.Hide
sysForm.Show
Else '密码错误
MsgBox "用户名或密码错误!", vbExclamation, "警告"
txtUserID.Text = ""
txtUserPwd.Text = ""
txtUserID.SetFocus
End If
End If
Exit Sub
err1:
MsgBox "用户名或密码错误!", vbExclamation, "警告"
Exit Sub
End Sub
Dim myConn As SqlConnection
Dim myComm As SqlCommand
Dim myDataread As SqlDataReader
myConn = New SqlConnection("server=127.0.0.1;integrated security=yes;database=pubs")
myConn.Open()
myComm = New SqlCommand("select * from employee where emp_id='" & TextBox1.Text & "' and fname='" & TextBox2.Text & "'", myConn)
myDataread = myComm.ExecuteReader
If myDataread.Read Then
Response.Write("登录成功")
Else
Response.Write("登录失败")
End If
myConn.Close()
Public Class myVBClass
Dim myConnectionString As String = "packet size=4096;user id=username;password=password;data source=198.168.1.1;persist security info=True;initial catalog=mypc"
Dim myConnection As New SqlConnection 'a conn
Dim myCommand As New SqlCommand 'a command 1
Dim myDataReader As SqlDataReader 'a read 2
Dim MyAdapter As New SqlDataAdapter 'a adapter 3
Function GetDataSet(ByVal tsql As String, ByVal name As String) As DataSet
Dim myDataSet As New DataSet
myDataSet.Clear()
myConnection = New SqlConnection(myConnectionString)
myConnection.Open()
myCommand.CommandText = tsql
myCommand.Connection = myConnection
MyAdapter.SelectCommand = myCommand
MyAdapter.Fill(myDataSet, name)
myConnection.Close()
Return myDataSet
End Function
end class