【求助】VB.NET开发web网站,登录页面如何实现不同用户登
vb.net吧
全部回复
仅看楼主
level 1
ainiyi53 楼主
现在有两类用户 管理员和用户 已创access 有以下字段 User password UID
user为用户名,password 密码 UID下面有 admin和user
现在要UID为admin的 用户 登录的是manage.aspx界面
user的用户登录default.aspx界面。代码要怎么写?
我小白一枚,自己写的,登录时混乱的。。。。。
2015年09月23日 08点09分 1
level 1
ainiyi53 楼主
Imports System.Data.OleDb
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Data
Imports System.Reflection
Imports Microsoft.Win32
Imports System.IO
Imports System.Web
Partial Class Denglu
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cnstr = "provider=microsoft.ace.oledb.12.0;data source=D:\网站学习\VQA CSS模板样式\Access\VQA.accdb"
Dim cn As OleDbConnection
cn = New OleDbConnection(cnstr)
'定义连接
cn.Open()
Dim sql As String = "select * from VQA_Psw where UserID='" & TextBox1.Text.Trim() & "'and UserPassword='" & TextBox2.Text() & "' "
Dim sqlCmd As OleDbCommand = New OleDbCommand(sql, cn)
Dim admins As String = "select*from VQA_Psw where Uid='" + "admin" + "'"
Dim sqllCmd As OleDbCommand = New OleDbCommand(admins, cn)
Dim denglu2 As Integer = sqlCmd.ExecuteScalar
Dim denglu As String = sqllCmd.ExecuteScalar
If denglu = "admin" And denglu2 > 0 Then
Response.Redirect("Manage.aspx")
ElseIf denglu2 > 0 And denglu <> "admin" Then
Response.Redirect("Default.aspx")
Else
MsgBox("登录错")
End If
End Sub
End Class
2015年09月23日 08点09分 2
level 12
Response.Redirect("Default.aspx")
这里前面你加一个判断不就可以了吗?
if TextBox1.Text.Trim()="admin" then
Response.Redirect("manage.aspx")
else
Response.Redirect("Default.aspx")
end if
2015年09月25日 03点09分 3
1