ユーザーごとに別々のウィンドウを開くログインフォームを作成したい タイプです。このプログラムデータベースには、3つのカラム(ユーザ名、パスワード、ユーザタイプ)があります。このユーザタイプは3つあります(admin、manager、user)&各ユーザタイプは別々のウィンドウを持っています。ユーザーごとに別のウィンドウを開く方法
- 管理者= Form2の
- マネージャー= たForm3
- ユーザー= Form4
ここでは私のログインボタンのコードです。それぞれのユーザータイプごとにこのウィンドウを個別に開きますようにしてください。 ウィンドウ
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 [email protected] and password [email protected]", con);
cmd.Parameters.AddWithValue("@username", textBox1.Text);
cmd.Parameters.AddWithValue("@password", textBox2.Text);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
if (dt.Rows.Count > 0)
{
Form3 Form = new Form3();
Form.Show();
this.Hide();
}
else
{
MessageBox.Show("Please enter Correct Username and Password");
}
マニッシュ仲間... – Sasindu
は –
を@Sasinduようこそ代わりの場合-else'、コメントをbro..anywayおかげで動作していない '切り替える-case' –