SubSonic Forums
All Your Database Are Belong To Us

insert, update, delete

Latest post 09-10-2008 5:18 AM by mongoose_za. 1 replies.
  • 09-10-2008 4:49 AM

    insert, update, delete

    Hihi

    I decided to ask all my questions at once rather then one at a time:/

    my code is as follows.

        private void BindNames()
        {               
            AddBook.DLL.AddressBookCollection list = new AddBook.DLL.AddressBookCollection().OrderByAsc("Name").Load();
            this.ddNames.DataSource = list;
            this.ddNames.DataTextField = "Name";
            this.ddNames.DataValueField = "UserID";
            this.ddNames.DataBind();
        }

        protected void btnSelect_Click(object sender, EventArgs e)
        {
            AddBook.DLL.AddressBook ab = new AddBook.DLL.AddressBook(ddNames.SelectedValue);
            this.tbName.Text = ab.Name;
            this.tbSurname.Text = ab.Surname;
            this.tbAddress.Text = ab.Address;
            this.tbHomePhone.Text = ab.HomePhone;
            this.tbMobilePhone.Text = ab.MobilePhone;      
        }


        protected void btnDelete_Click(object sender, EventArgs e)
        {
            AddBook.DLL.AddressBook ab = new AddBook.DLL.AddressBook(ddNames.SelectedValue);
            AddBook.DLL.AddressBook.Delete(ab.UserID);
            BindNames();       
        }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
           
        }
        protected void btnInsert_Click(object sender, EventArgs e)
        {
            AddBook.DLL.AddressBook ab = new AddBook.DLL.AddressBook();
            ab.Name = tbName.Text;
            ab.Surname = tbSurname.Text;
            ab.Address = tbAddress.Text;
            ab.HomePhone = tbHomePhone.Text;
            ab.MobilePhone = tbMobilePhone.Text;
            ab.Save();
            BindNames();
        }

     

    I've got my select, i've got a delete and i have an insert. I'm not sure if it's done in the proper way but that's how i've done it in the meatime. If there's a better way or safer way please comment away.

    There is no update though. Please show me how you would update.

    Thanks alot.

     

    Filed under: , ,
  • 09-10-2008 5:18 AM In reply to

    Re: insert, update, delete

    Reply |Contact |Answer

        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            AddBook.DLL.AddressBook ab = new AddBook.DLL.AddressBook(ddNames.SelectedValue);
            ab.Name = tbName.Text;
            ab.Surname = tbSurname.Text;
            ab.Address = tbAddress.Text;
            ab.HomePhone = tbHomePhone.Text;
            ab.MobilePhone = tbMobilePhone.Text;
            ab.Save();
            BindNames();
           
        }

    here is what i did for update. So for all the noobs out there here are the basic INSERT UPDATE DELETE using SS. Hope it helps. And if any gosus see this and think there are better ways please lemme know. :D

Page 1 of 1 (2 items) | RSS