Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Im writing a vb project on report posting. I have a login page and I have set an admin password and username inside my MySQL database and other user passwords also. I want my add-user form to open if only admin logs in

What I have tried:

VB
If
Textbox1.text=("admin") and textbox2.text= ("admin")then
Me.hide
Dim Dio= new add_ user
Dio.show
Else
Msgbox.show ("you don't have permission")
End if
Posted
Updated 5-Apr-23 21:42pm
v2
Comments
Ralf Meier 6-Apr-23 2:36am    
if you want to have a solution you should give much more information. This code-snippet says nothing to me. What is your goal ? Should we write the code for you ?

1 solution

That username and password combination isn't in a database at all: they are hardcoded into your app.
So if you are entering the data you added to your DB, unless it's also "admin" and "admin" it's never going to match and you will always get "you don't have permission".

I'd also say that you should do yourself a favour, and stop using Visual Studio default names for everything - you may remember that "TextBox8" is the mobile number today, but when you have to modify it in three weeks time, will you then? Use descriptive names - "tbMobileNo" for example - and your code becomes easier to read, more self documenting, easier to maintain - and surprisingly quicker to code because Intellisense can get to to "tbMobile" in three keystrokes, where "TextBox8" takes thinking about and 8 keystrokes...
Are you sure that the username and password are in "Textbox1" and "Textbox2"?

If you are absolutely sure on all of that, then use the debugger to make sure that that code is being executed at all, and to find out exactly what it does when it runs.

Sorry, but we can't do any of that for you!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900