请教大家一个开发中遇到的问题! SQL 可以实现它有 用户管理功能ASS 用程序吧, 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 1 添加删除用户(我的一个实用窗体,超级管理员可以添加删除管理员) VERSION 5.00Begin VB.Form frm_SysAdmin BorderStyle = 1 'Fixed Single Caption = "增加/删除管理员" ClientHeight = 4335 ClientLeft = 45 ClientTop = 330 ClientWidth = 4500 Icon = "frmSysAdmin.frx":0000 KeyPreview = -1 'True LinkTopic = "Form1" MaxButton = 0 'False MinButton = 0 'False ScaleHeight = 4335 ScaleWidth = 4500 StartUpPosition = 2 '屏幕中心 Begin VB.CommandButton Command3 Cancel = -1 'True Caption = "返回" Height = 495 Left = 2760 TabIndex = 9 Top = 3480 Width = 1335 End Begin VB.CommandButton Command2 Caption = "4" BeginProperty Font Name = "Webdings" Size = 15.75 Charset = 2 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Left = 2760 TabIndex = 8 Top = 2760 Width = 1335 End Begin VB.CommandButton Command1 Caption = "3" Default = -1 'True BeginProperty Font Name = "Webdings" Size = 15.75 Charset = 2 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Left = 2760 TabIndex = 7 Top = 2040 Width = 1335 End Begin VB.TextBox txtPWD Height = 270 IMEMode = 3 'DISABLE Index = 1 Left = 1680 MaxLength = 16 PasswordChar = "*" TabIndex = 2 Top = 1320 Width = 2415 End Begin VB.TextBox txtPWD Height = 270 IMEMode = 3 'DISABLE Index = 0 Left = 1680 MaxLength = 16 PasswordChar = "*" TabIndex = 1 Top = 960 Width = 2415 End Begin VB.TextBox txtName Height = 270 IMEMode = 1 'ON Left = 1680 MaxLength = 20 TabIndex = 0 Top = 360 Width = 2415 End Begin VB.ListBox List1 Height = 1860 Left = 360 TabIndex = 3 Top = 2040 Width = 2055 End Begin VB.Label Label2 AutoSize = -1 'True Caption = "确认口令:" Height = 180 Index = 1 Left = 480 TabIndex = 6 Top = 1320 Width = 900 End Begin VB.Label Label2 AutoSize = -1 'True Caption = "预设口令:" Height = 180 Index = 0 Left = 480 TabIndex = 5 Top = 960 Width = 900 End Begin VB.Label Label1 AutoSize = -1 'True Caption = "管理员姓名:" Height = 180 Left = 480 TabIndex = 4 Top = 360 Width = 1080 EndEndAttribute VB_Name = "frm_SysAdmin"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalseOption ExplicitDim cnn As New ADODB.Connection, rs As RecordsetPrivate Sub Command1_Click()Dim n As LongIf Trim(txtName) = "" ThenMSG "姓名不能空缺", 3txtName.SetFocusExit SubEnd IfIf Trim(txtPWD(0)) <> Trim(txtPWD(1)) ThenMSG "口令确认有误", 3txtPWD(0).SetFocusExit SubEnd Ifn = FindStringinListControl(List1, Trim(txtName))If n >= 0 ThenMSG Trim(txtName) & "已经存在", 3List1.ListIndex = ntxtName.SetFocusExit SubEnd Ifrs.AddNewrs!Name = Trim(txtName)rs!Password = Trim(txtPWD(0))rs.UpdateList1.AddItem Trim(txtName)txtName.SetFocusEnd SubPrivate Sub Command2_Click()If List1.ListIndex = -1 Then Exit Subrs.Requeryrs.Find "name='" & List1.List(List1.ListIndex) & "'"rs.DeleteList1.RemoveItem List1.ListIndexEnd SubPrivate Sub Command3_Click()Unload MeEnd SubPrivate Sub Form_Load()cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=consume.mdb;Persist Security Info=False" & ";Jet OLEDB:Database Password=" & dbPwdcnn.CursorLocation = adUseClientList1.ClearSet rs = New ADODB.RecordsetSet rs.ActiveConnection = cnnrs.Open "select * from admin where name <> '超级管理员'", cnn, adOpenStatic, adLockOptimisticDo While Not rs.EOFList1.AddItem rs!Namers.MoveNextLoopIf List1.ListCount > 0 Then List1.ListIndex = 0End SubPrivate Sub Form_Unload(Cancel As Integer)rs.CloseSet rs = Nothingcnn.CloseSet cnn = NothingEnd SubPrivate Sub txtName_GotFocus()txtName.SelStart = 0txtName.SelLength = 20End SubPrivate Sub txtPWD_GotFocus(Index As Integer)txtPWD(Index).SelStart = 0txtPWD(Index).SelLength = 16End Sub2 在模块中声明一个公共变量public currentUser as string当用户登录时,赋给它用户名。进入任何一个浏览内容的窗体时,根据currentUser确定他的范围,用不同的SQL where字句提取数据。 在表里除了保存用户名和密码外加一个字段表示该用户的权限比如admin可以设为255...普通用户可以为1,高级用户为10...等在程序中判断该用户的权限值然后提供相应的功能给该用户 如何将前N个记录的某数据字段求和后插在N,N+1条记录之间?用SQL实现。 关于论坛顶贴机的问题! SysTreeview32 VB 远程注入/卸载/自我删除(RtlCreateUserThread) 请教下树型控件直接取数据表的数值后的问题 想要找一个把所有磁盘都显示出来的控件 进程条问题? 客户端怎么连接服务器端的oracle数据库 30分请教一个简单问题! 如何测试A驱是否有盘? 有那些比较好的VB网站?推荐一下吧!!谢谢 改变鼠标的坐标,让鼠标自动在屏幕上动!!!! 怎样写一个dll用来下载网页
VERSION 5.00
Begin VB.Form frm_SysAdmin
BorderStyle = 1 'Fixed Single
Caption = "增加/删除管理员"
ClientHeight = 4335
ClientLeft = 45
ClientTop = 330
ClientWidth = 4500
Icon = "frmSysAdmin.frx":0000
KeyPreview = -1 'True
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4335
ScaleWidth = 4500
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command3
Cancel = -1 'True
Caption = "返回"
Height = 495
Left = 2760
TabIndex = 9
Top = 3480
Width = 1335
End
Begin VB.CommandButton Command2
Caption = "4"
BeginProperty Font
Name = "Webdings"
Size = 15.75
Charset = 2
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 2760
TabIndex = 8
Top = 2760
Width = 1335
End
Begin VB.CommandButton Command1
Caption = "3"
Default = -1 'True
BeginProperty Font
Name = "Webdings"
Size = 15.75
Charset = 2
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 2760
TabIndex = 7
Top = 2040
Width = 1335
End
Begin VB.TextBox txtPWD
Height = 270
IMEMode = 3 'DISABLE
Index = 1
Left = 1680
MaxLength = 16
PasswordChar = "*"
TabIndex = 2
Top = 1320
Width = 2415
End
Begin VB.TextBox txtPWD
Height = 270
IMEMode = 3 'DISABLE
Index = 0
Left = 1680
MaxLength = 16
PasswordChar = "*"
TabIndex = 1
Top = 960
Width = 2415
End
Begin VB.TextBox txtName
Height = 270
IMEMode = 1 'ON
Left = 1680
MaxLength = 20
TabIndex = 0
Top = 360
Width = 2415
End
Begin VB.ListBox List1
Height = 1860
Left = 360
TabIndex = 3
Top = 2040
Width = 2055
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "确认口令:"
Height = 180
Index = 1
Left = 480
TabIndex = 6
Top = 1320
Width = 900
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "预设口令:"
Height = 180
Index = 0
Left = 480
TabIndex = 5
Top = 960
Width = 900
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "管理员姓名:"
Height = 180
Left = 480
TabIndex = 4
Top = 360
Width = 1080
End
End
Attribute VB_Name = "frm_SysAdmin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim cnn As New ADODB.Connection, rs As RecordsetPrivate Sub Command1_Click()
Dim n As LongIf Trim(txtName) = "" Then
MSG "姓名不能空缺", 3
txtName.SetFocus
Exit Sub
End If
If Trim(txtPWD(0)) <> Trim(txtPWD(1)) Then
MSG "口令确认有误", 3
txtPWD(0).SetFocus
Exit Sub
End If
n = FindStringinListControl(List1, Trim(txtName))
If n >= 0 Then
MSG Trim(txtName) & "已经存在", 3
List1.ListIndex = n
txtName.SetFocus
Exit Sub
End Ifrs.AddNew
rs!Name = Trim(txtName)
rs!Password = Trim(txtPWD(0))
rs.Update
List1.AddItem Trim(txtName)
txtName.SetFocus
End SubPrivate Sub Command2_Click()
If List1.ListIndex = -1 Then Exit Sub
rs.Requery
rs.Find "name='" & List1.List(List1.ListIndex) & "'"
rs.Delete
List1.RemoveItem List1.ListIndex
End SubPrivate Sub Command3_Click()
Unload Me
End SubPrivate Sub Form_Load()
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=consume.mdb;Persist Security Info=False" & ";Jet OLEDB:Database Password=" & dbPwd
cnn.CursorLocation = adUseClient
List1.Clear
Set rs = New ADODB.Recordset
Set rs.ActiveConnection = cnn
rs.Open "select * from admin where name <> '超级管理员'", cnn, adOpenStatic, adLockOptimistic
Do While Not rs.EOF
List1.AddItem rs!Name
rs.MoveNext
Loop
If List1.ListCount > 0 Then List1.ListIndex = 0
End SubPrivate Sub Form_Unload(Cancel As Integer)
rs.Close
Set rs = Nothing
cnn.Close
Set cnn = Nothing
End Sub
Private Sub txtName_GotFocus()
txtName.SelStart = 0
txtName.SelLength = 20
End SubPrivate Sub txtPWD_GotFocus(Index As Integer)
txtPWD(Index).SelStart = 0
txtPWD(Index).SelLength = 16
End Sub2 在模块中声明一个公共变量public currentUser as string
当用户登录时,赋给它用户名。
进入任何一个浏览内容的窗体时,根据currentUser确定他的范围,用不同的SQL where字句提取数据。
加一个字段表示该用户的权限比如admin可以设为255...普通用户可以为1,高级用户为10...等在程序中判断该用户的权限值然后提供相应的功能给该用户