What's new

Help Vb.net questions

PHC-Xes

Forum Guru
Elite
Pahelp po paturo po kapag po CS nasa combobox mag proceed po
1623737229517.png

1623737218645.png
 
C#:
Dim con As SqlConnection = New SqlConnection("Data Source=DESKT...

If ComboBox1.Text = "ADMIN" Then
   Dim cmd As SQLCommand = New SqlCommand("Select * from TBLUSER where USERNAME..
   ...
   ...
Else
   Dim cmd As SQLCommand = New SqlCommand("Select * from TBLCSUSER where USERNAME..
   ...
   ...
End If
 
String Username;
String Password:
String Role;

Get the values of Username & Password pass them to string. reason (To prevent SQL Injection)

Actually there is simple way to create this.
Create one Database for all Users.
Username, Password, Role.

Query 1.
SELECT * FROM USERS_TBL WHERE Username="Administrator" and Password="Password" and Role="Administrator" ;
Query 2.
SELECT * FROM USERS_TBL WHERE Username="Administrator" and Password="Password" and Role="CS" ;

the best way to differentiate them is to use two different queries.
If the query one fail to get results.
you can use Query 2.
you can even remove combobox this way.

I hate to do this but this is the only close solution you can use for now.
there is more complicated way to do this. is to pass all data from users to arrays/model and do authentication by matching values using for loop.

I recommend you learn how to use classes, arrays & model. I find it hard to other student that prof don't teach this at school. you can try to ask your prof.

Thanks for calling jncndlcpa.
 
Last edited:

Similar threads

Back
Top