1 / 23

Linq to sql

Linq to sql. Anj(^^,). Connecting to DB Displaying Data Inserting Data Updating Data Deleting Data Sample Program. contents. Connecting to db. Connecting to db (cont’d.). Right-click project Add... New Item. Connecting to db (cont’d.). Connecting to db (cont’d.).

crwys
Download Presentation

Linq to sql

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Linq to sql Anj(^^,)

  2. Connecting to DB Displaying Data Inserting Data Updating Data Deleting Data Sample Program contents

  3. Connecting to db

  4. Connecting to db (cont’d.) Right-click project Add... New Item

  5. Connecting to db (cont’d.)

  6. Connecting to db (cont’d.) Drag and drop table/s

  7. Connecting to db (cont’d.) Yes

  8. Connecting to db (cont’d.)

  9. Connecting to db (cont’d.)

  10. Right-click References Add Reference.. See highlight

  11. Import the proper references on the .cs as necessary. See highlight

  12. Displaying data sampleDBDataContextdb = new sampleDBDataContext(@“PATH\sampleDB.mdf"); var records = from user in db.sampleTables orderby user.ID select user; dgvRecords.DataSource = records;

  13. Inserting data sampleDBDataContextdb = new sampleDBDataContext(@“PATH\sampleDB.mdf"); Table<sampleTable> users = db.GetTable<sampleTable>(); sampleTablenewUser = new sampleTable(); newUser.Name= txtName.Text; newUser.Username= txtUname.Text; newUser.Password = txtPassword.Text; users.InsertOnSubmit(newUser); users.Context.SubmitChanges();

  14. Editing data sampleDBDataContextdb = new sampleDBDataContext(@“PATH\sampleDB.mdf"); var match = (from user in db.sampleTables where user.ID == rowID select user).First(); match.Name= txtName.Text; match.Username= txtUname.Text; match.Password= txtPassword.Text; users.Context.SubmitChanges();

  15. Deleting data sampleDBDataContextdb = new sampleDBDataContext(@“PATH\sampleDB.mdf"); Table<sampleTable> users = db.GetTable<sampleTable>(); varmatch = (from user in db.sampleTables where user.ID == rowID select user).First(); users.DeleteOnSubmit(match); users.Context.SubmitChanges();

  16. Login.cs ManageData.cs DisplayInfo.cs AddEdit.cs sample program

  17. Login • Validate credentials • CLEAR – clears text fields • SUBMIT – submits entered data • Valid credentials – go to ManageData form • Invalid credentials – display a message box

  18. Login (cont’d.) • Added feature • Password is not seen as the user types

  19. managedata • DATAGRID – display and sorting of data • SEARCH – search for a specific user’s information (must be exact) • ADD – add new user • EDIT – edit existing user’s record • DELETE – delete existing user’s record upon confirmation • FILTER – realtime filter of data displayed in datagrid • X – reset filters

  20. Managedata (cont’d.) • Added features • Full-row select on datagrid • Display specific user’s information upon double click on selected row • Enable search only when a radio button is clicked • Limit input to integers only when search option is by ID • Limit input to letters and spaces only when search option is by Name • Use same form when Add or Edit button is clicked • From date cannot be later than To date • To date cannot be earlier than From date

  21. displayinfo • Used to display an existing user’s information

  22. Addedit • Used to add new user or edit existing user’s information • SUBMIT – submits entered data • CLEAR – clears textboxes • CANCEL – returns to ManageData form

  23. Addedit (Cont’d.) • Added features • Limit input to letters and spaces only on the Name textbox • Submit only when there is no blank field left

More Related