Private Sub BtnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOK.Click Dim result As Integer = myDB.Userlogin(Username.Text,Userpass.Text) If result > 0 Then Response.Cookies("myCookies")("myID") = result Response.Redirect("AdminMain.html") Else myError() End If End Sub '登录 Public Function Userlogin(ByVal Username As String, ByVal Userpass As String) As Integer mySql = "select ID from Userinfo where Username=" & str(Username) & " and Userpass='" & Userpass & "'" Dim result As Integer = ExecScalar(mySql) If result > 0 Then Return 1 Else Return 0 End If End Function Public Function ExecScalar(ByVal mySql As String) As Object Dim myConn As New OleDbConnection(strConn) Dim myCmd As OleDbCommand = myConn.CreateCommand myCmd.CommandText = mySql myConn.Open() Dim myTmp As Object = myCmd.ExecuteScalar() myCmd.Dispose() myConn.Close() Return myTmp End Function
Dim result As Integer = myDB.Userlogin(Username.Text,Userpass.Text)
If result > 0 Then
Response.Cookies("myCookies")("myID") = result
Response.Redirect("AdminMain.html")
Else
myError()
End If
End Sub '登录
Public Function Userlogin(ByVal Username As String, ByVal Userpass As String) As Integer
mySql = "select ID from Userinfo where Username=" & str(Username) & " and Userpass='" & Userpass & "'"
Dim result As Integer = ExecScalar(mySql)
If result > 0 Then
Return 1
Else
Return 0
End If
End Function Public Function ExecScalar(ByVal mySql As String) As Object
Dim myConn As New OleDbConnection(strConn)
Dim myCmd As OleDbCommand = myConn.CreateCommand
myCmd.CommandText = mySql
myConn.Open()
Dim myTmp As Object = myCmd.ExecuteScalar()
myCmd.Dispose()
myConn.Close()
Return myTmp
End Function