[vb]代码库
Public Sub connect()
Dim pass As Boolean
pass = False
Dim conn As New SqlConnection
Dim rs As New SqlCommand
Dim dataread As SqlDataReader
Dim constr As String
'Dim i As Integer
Dim sql As String
constr = "server=PC-201105311336\SQLEXPRESS;Uid=sa;Pwd=123456;Database=jiaxiaoai" '无源连接
conn = New SqlConnection(constr)
conn.Open()
sql = "select * from sysname"
rs = New SqlCommand(sql, conn)
dataread = rs.ExecuteReader()
While (dataread.Read)
If dataread(0).ToString = usertext.Text And dataread(1).ToString = passwordtext.Text Then
pass = True
End If
End While
If pass = True Then
Me.Hide()
显示学生信息.Show()
Else
MsgBox("用户名或密码错误")
End If
End Sub