public int Insert(Student s)
        {
            string query = "Insert into Student (Name,Age,Roll) values('" + s.Name + "'," + s.Age + "," + s.Roll + ")";
            int res = base.InsertUpdateDelete(query);

            return res;
        }
        public List<Student> StdSelectAll()
        {
            reader = base.SelectAll("Student");
            List<Student> list=new List<Student>();
            while (reader.Read())
            {
                Student temp = new Student();
                temp.SN = Convert.ToInt32(reader["SN"]);
                temp.Name = Convert.ToString(reader["Name"]);
                temp.Age = Convert.ToInt32(reader["Age"]);
                temp.Roll = Convert.ToInt32(reader["Roll"]);
                list.Add(temp);

            }

            return list;
        }
Beispiel #3
0
        private void button4_Click(object sender, EventArgs e)
        {
            Student s=new Student();
               // s.SN = Convert.ToInt32(SnTextbox.Text);
            s.Name = NameTextbox.Text;
            s.Roll = Convert.ToInt32(RollTextbox.Text);
            s.Age = Convert.ToInt32(AgeTextbox.Text);
            StudentDb sdb=new StudentDb();
            int result=sdb.Insert(s);

            if(result==-1)
            {
                MessageBox.Show("couldn't be inserted");
            }

            else
            {
                MessageBox.Show(result+" Row inserted");
            }
        }
 public int Update(Student s)
 {
     string query = "Update Student set Name='" + s.Name + "',Age=" + s.Age +",Roll=" + s.Roll;
     int res = base.InsertUpdateDelete(query);
     return res;
 }