private void submitBtn_Click(object sender, EventArgs e) { try { //int companyId = 0; //DatabaseClass db = new DatabaseClass(); //db.openConnection(); //var cmd = db.cmd("selectCompany"); //cmd.CommandType = CommandType.StoredProcedure; //cmd.Parameters.AddWithValue("@userName", SqlDbType.NVarChar).Value = userNameTxt.Text.Trim(); //cmd.Parameters.AddWithValue("@password", SqlDbType.NVarChar).Value = passwordTxt.Text.Trim(); //DataTable dt = new DataTable(); //dt.Load(cmd.ExecuteReader()); //db.closeConnection(); int companyId = 0; DatabaseClass db = new DatabaseClass(); SqlParameter[] param = { new SqlParameter("@userName", SqlDbType.NVarChar) { Value = userNameTxt.Text.Trim() }, new SqlParameter("@password", SqlDbType.NVarChar) { Value = passwordTxt.Text.Trim() } }; var command = db.cmd("selectCompany", param); DataTable dt = new DataTable(); db.openConnection(); dt.Load(command.ExecuteReader()); db.closeConnection(); companyId = dt.Rows[0].Field <int>(0); if (dt.Rows.Count > 0) { mainForm main = new mainForm(companyId); main.Show(); this.Hide(); } else { MessageBox.Show("برجاء أدخل اسم مستخدم و كلمة سر صحيحة "); } } catch (Exception es) { MessageBox.Show("برجاء أدخل اسم مستخدم و كلمة سر"); } }