Hi guy's i am using vb6 and sql server 2000 and i create my login form and already connected to the sql i am wondering how to make some restriction on login. Sample when i login Admin i can access everything in form2 but when i login kobe some buttons or textbox i can't access. How could i do that? Need a big help guy's
Define a Global Boolean variable in your module and set them to true when there is an admin login and set them to false when user logs in. Depending upon that variable enable/disable you buttons/text box
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread "Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
Define a Global Boolean variable in your module and set them to true when there is an admin login and set them to false when user logs in. Depending upon that variable enable/disable you buttons/text box
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video) My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet Social Group:VBForums - Developers from India
It's more work and some research but if this is an application of any substance and will reside in a commercial production environment learn to use DB roles versus hardcoding IDs as in the example by akhileshbc. If it is something small and just controled by you the example is fine.
@TysonLPrice: Can you give me a small example description regarding DB roles ?
Thanks..
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video) My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet Social Group:VBForums - Developers from India
Thank's for the info sir but what if my user and password are stored in my datatabase and not on my form. How to restrict it? Same as you do?
In the login form, try the username and password checking using data from your database. Then, assign the user role based on that user.
@TysonLPrice: That's ok. I'll wait
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video) My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet Social Group:VBForums - Developers from India
I cant get what you say sir please clarify me what to do. sorry for that
It will be something like this (for example):
Code:
Option Explicit
Private Sub cmdOK_Click()
'~~~ Add reference to Microsoft ActiveX Data Objects 2.x Library
'~~~ We are going to check the database for the entered username and password. You need to make the necessary changes to suit your needs
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source= " & App.Path & "\database.mdb;Persist Security Info=False;Jet OLEDB:Database Password=myDBpassword;"
cn.Open
Set rs = New ADODB.Recordset
rs.Open "SELECT * FROM all_users WHERE user_name = '" & Trim$(txtUserName.Text) & "' AND password = '" & txtPassword.Text & "'", cn, adOpenForwardOnly, adLockReadOnly
If rs.EOF = False Then
Select Case LCase$(txtUserName.Text)
Case "admin"
myUser = user_Admin
Form1.Show
Unload frmLogin
Exit Sub
Case "guest"
myUser = user_Guest
Form1.Show
Unload frmLogin
Exit Sub
Case "normal"
myUser = user_Normal
Form1.Show
Unload frmLogin
Exit Sub
End Select
End If
MsgBox "Invalid Password, try again!", , "Login"
txtPassword.SetFocus
SendKeys "{Home}+{End}"
End Sub
You need to read the articles and tutorials in our Database Development FAQ section to know more about database manipulation.
Good luck...
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video) My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet Social Group:VBForums - Developers from India
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video) My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet Social Group:VBForums - Developers from India
I am using this codes to show the values in combo box but when i run it nothing happens i did not get anything to the database.
Then, you have to provide us more details for checking that issue. Like the sub that deals with the database (set_rec_getData) and other things.
....
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video) My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet Social Group:VBForums - Developers from India
Ok. Where's the connection ? Have you dealt with database before ?
Does it show any errors ? Did you checked your database - i mean, does it have any records ?
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video) My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet Social Group:VBForums - Developers from India