Sasindu Sasindu - 1 year ago 64
SQL Question

How to open separate window for each user

I want to make a login form which open separate window for each user
type. In this program database have 3 columns.(username, password ,usertype) there are 3 user types in this program (admin, manager, user) & each user type have separate window.

  1. admin = Form2

  2. manager = Form3

  3. user = Form4

Here is my login button code. Please, help me to make this open separate
window for each user type.

SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=c:\users\sasindu\documents\visual studio 2010\Projects\Employee Database\Employee Database\Database.mdf;Integrated Security=True;User Instance=True");
SqlCommand cmd = new SqlCommand("select * from login where username=@username and password =@password", con);
cmd.Parameters.AddWithValue("@username", textBox1.Text);
cmd.Parameters.AddWithValue("@password", textBox2.Text);

SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
int i = cmd.ExecuteNonQuery();


if (dt.Rows.Count > 0)
Form3 Form = new Form3();
MessageBox.Show("Please enter Correct Username and Password");

Answer Source

I think you have add a column in login table user type . user type column has derive admin,user,manager etc. Then you will easily verify

// which form you show


// which form you show


// which form you show


i hope this code help you.if any query please comment.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download