protected void btnsubmit_Click(object sender, EventArgs e)
        {
            Student student = new Student();
            student.UserName = txtuser.Text;
            student.Password = txtpwd.Text;
            student.ConfirmPassword = txtcnmpwd.Text;
            student.FirstName = txtfname.Text;
            student.LastName = txtlname.Text;
            student.Email = txtEmail.Text;
            student.Phone = txtphone.Text;
            student.Location = txtlocation.Text;

            var i = DAL.InsertAdmissionInfo(student);
            Response.Redirect("welcome.aspx");

            /*
                        string cs = System.Configuration.ConfigurationManager.ConnectionStrings["Myconnection"].ConnectionString;
                        SqlConnection connection = new SqlConnection(cs);
                        SqlCommand cmd = new SqlCommand("insert into student2(Username,Password,ConfirmPassword,FirstName,LastName,Email,Phone,Location)values('"+txtuser.Text+"','"+txtpwd.Text+"','"+txtcnmpwd.Text+"','"+txtfname.Text+"','"+txtlname.Text+"','"+txtEmail.Text+"','"+txtphone.Text+"','"+txtlocation.Text+"')",connection);
                        connection.Open();
                        cmd.ExecuteNonQuery();
                        connection.Close();
                        Response.Redirect("Welcome.aspx");

                    }*/
        }
Пример #2
0
        public static List<Student> GetAllStudent()
        {
            List<Student> listStudent = new List<Student>();
            string cs1 = ConfigurationManager.ConnectionStrings["Myconnection"].ConnectionString;
            SqlConnection connection = new SqlConnection(cs1);
            connection.Open();
            string qry1 = "select* from student2";
            SqlCommand cmd = new SqlCommand(qry1, connection);
            SqlDataReader rdr = cmd.ExecuteReader();
            while (rdr.Read())
            {
                Student student = new Student();
                student.UserName = rdr[0].ToString();
                student.Password = rdr[1].ToString();
                student.ConfirmPassword = rdr[2].ToString();
                student.FirstName = rdr[3].ToString();
                student.LastName = rdr[4].ToString();
                student.Email = rdr[5].ToString();
                student.Phone = rdr[6].ToString();
                student.Location = rdr[7].ToString();

                listStudent.Add(student);
            }
            connection.Close();
            return listStudent;
        }
Пример #3
0
        public static int DeleteInfo(Student student)
        {
            string cs1 = ConfigurationManager.ConnectionStrings["Myconnection"].ConnectionString;
            SqlConnection connection = new SqlConnection(cs1);

                connection.Open();
                string qry = "delete from student2";

                SqlCommand cmd = new SqlCommand(qry, connection);
              int i=  cmd.ExecuteNonQuery();
              connection.Close();
              return i;
        }
Пример #4
0
        public static int InsertAdmissionInfo(Student Student)
        {
            //OleDbConnection connection = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Waliul\Desktop\StudentAdmssion.accdb");
            string cs1 = ConfigurationManager.ConnectionStrings["Myconnection"].ConnectionString;
            SqlConnection connection = new SqlConnection(cs1);
            connection.Open();
            SqlCommand o_cmd = new SqlCommand("insert into student2 values(@a,@b,@c,@d,@e,@f,@g,@h)", connection);
            o_cmd.Parameters.AddWithValue("a", Student.UserName);
            o_cmd.Parameters.AddWithValue("b", Student.Password);
            o_cmd.Parameters.AddWithValue("c", Student.ConfirmPassword);
            o_cmd.Parameters.AddWithValue("d", Student.FirstName);
            o_cmd.Parameters.AddWithValue("e", Student.LastName);
            o_cmd.Parameters.AddWithValue("f", Student.Email);
            o_cmd.Parameters.AddWithValue("g", Student.Phone);
            o_cmd.Parameters.AddWithValue("h", Student.Location);

            int i = o_cmd.ExecuteNonQuery();
            connection.Close();
            return i;
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            Student student = new Student();

            var i = DAL.DeleteInfo(student);
        }